break eop stakeholder into multiple fields

This commit is contained in:
matthewswspence 2025-03-17 16:04:24 -05:00
parent 44da71b007
commit b2fd131c30
No known key found for this signature in database
GPG key ID: FB458202A7852BA4
5 changed files with 56 additions and 47 deletions

View file

@ -147,8 +147,6 @@ class EOPContactForm(BaseDeletableRegistrarForm):
Executive Branch (FEB) agency is working with.
"""
field_name = "eop_contact"
first_name = forms.CharField(
label="First name / given name",
error_messages={"required": "Enter the first name / given name of this contact."},
@ -178,12 +176,10 @@ class EOPContactForm(BaseDeletableRegistrarForm):
@classmethod
def from_database(cls, obj):
if not obj.eop_contact:
return {}
return {
"first_name": obj.eop_contact.first_name,
"last_name": obj.eop_contact.last_name,
"email": obj.eop_contact.email,
"first_name": obj.eop_stakeholder_first_name,
"last_name": obj.eop_stakeholder_last_name,
"email": obj.eop_stakeholder_email,
}
def to_database(self, obj):
@ -195,11 +191,9 @@ class EOPContactForm(BaseDeletableRegistrarForm):
return
if not self.is_valid():
return
obj.eop_contact = Contact.objects.create(
first_name=self.cleaned_data["first_name"],
last_name=self.cleaned_data["last_name"],
email=self.cleaned_data["email"],
)
obj.eop_stakeholder_first_name = self.cleaned_data["first_name"]
obj.eop_stakeholder_last_name = self.cleaned_data["last_name"]
obj.eop_stakeholder_email = self.cleaned_data["email"]
obj.save()