added check if creator exists

This commit is contained in:
asaki222 2024-08-07 14:59:17 -04:00
parent 46769cb8a6
commit b5330e1c38
No known key found for this signature in database
GPG key ID: CDC41B4E3DF6857F

View file

@ -2866,6 +2866,9 @@ class PortfolioAdmin(ListHeaderAdmin):
def save_model(self, request, obj, form, change): def save_model(self, request, obj, form, change):
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 obj.creator = request.user if request.user.is_authenticated else None
# ---- update organization name ---- # ---- update organization name ----
# org name will be the same as federal agency, if it is federal, # org name will be the same as federal agency, if it is federal,