fix eop contact deletable functionality

This commit is contained in:
matthewswspence 2025-03-12 10:52:19 -05:00
parent 398958e1bf
commit 71c3332c72
No known key found for this signature in database
GPG key ID: FB458202A7852BA4

View file

@ -177,16 +177,21 @@ class EOPContactForm(BaseDeletableRegistrarForm):
@classmethod
def from_database(cls, obj):
# if not obj.eop_contact:
# return {}
# return {
# "first_name": obj.feb_eop_contact.first_name,
# "last_name": obj.feb_eop_contact.last_name,
# "email": obj.feb_eop_contact.email,
# }
return {}
if not obj.eop_contact:
return {}
return {
"first_name": obj.feb_eop_contact.first_name,
"last_name": obj.feb_eop_contact.last_name,
"email": obj.feb_eop_contact.email,
}
def to_database(self, obj):
# This function overrides the behavior of the BaseDeletableRegistrarForm.
# in order to preserve deletable functionality, we need to call the
# superclass's to_database method if the form is marked for deletion.
if self.form_data_marked_for_deletion:
super().to_database(obj)
return
if not self.is_valid():
return
obj.eop_contact = Contact.objects.create(