From 71c3332c72fe2667f1e48f55137d06a5229a7df0 Mon Sep 17 00:00:00 2001 From: matthewswspence Date: Wed, 12 Mar 2025 10:52:19 -0500 Subject: [PATCH] fix eop contact deletable functionality --- src/registrar/forms/feb.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/registrar/forms/feb.py b/src/registrar/forms/feb.py index 4342acdba..e14e2741e 100644 --- a/src/registrar/forms/feb.py +++ b/src/registrar/forms/feb.py @@ -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(