From b5330e1c38e3362c6f9174f1d7b1233599e9e16e Mon Sep 17 00:00:00 2001 From: asaki222 Date: Wed, 7 Aug 2024 14:59:17 -0400 Subject: [PATCH] added check if creator exists --- src/registrar/admin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/registrar/admin.py b/src/registrar/admin.py index 6543138af..5e2870042 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -2865,8 +2865,11 @@ class PortfolioAdmin(ListHeaderAdmin): return super().change_view(request, object_id, form_url, extra_context) def save_model(self, request, obj, form, change): - - obj.creator = request.user if request.user.is_authenticated else None + + if hasattr(obj, 'creator') is False: + # ---- update creator ---- + # Set the creator field to the current admin user + obj.creator = request.user if request.user.is_authenticated else None # ---- update organization name ---- # org name will be the same as federal agency, if it is federal, # otherwise it will be the actual org name. If nothing is entered for