From 70dfccbb2e2c0302b2bd544da481a85a77379a1d Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Wed, 17 Jan 2024 13:39:33 -0500 Subject: [PATCH] small refactors and linting --- src/registrar/forms/domain.py | 7 ++----- src/registrar/models/contact.py | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/registrar/forms/domain.py b/src/registrar/forms/domain.py index 030fac86d..e29a2bb6f 100644 --- a/src/registrar/forms/domain.py +++ b/src/registrar/forms/domain.py @@ -250,11 +250,8 @@ class AuthorizingOfficialContactForm(ContactForm): # has more than one joined object. # In this case, create a new Contact, and update the new Contact with form data. # Then associate with domain information object as the authorizing_official - contact = Contact() - for name, value in self.cleaned_data.items(): - setattr(contact, name, value) - contact.save() - self.domainInfo.authorizing_official = contact + data = dict(self.cleaned_data.items()) + self.domainInfo.authorizing_official = Contact.objects.create(**data) self.domainInfo.save() else: super().save() diff --git a/src/registrar/models/contact.py b/src/registrar/models/contact.py index d8c94398b..00f27ae56 100644 --- a/src/registrar/models/contact.py +++ b/src/registrar/models/contact.py @@ -56,7 +56,7 @@ class Contact(TimeStampedModel): def _get_all_relations(self): return [f.name for f in self._meta.get_fields() if f.is_relation] - + def has_more_than_one_join(self, expected_relation): """Helper for finding whether an object is joined more than once. expected_relation is the one relation with one expected join"""