Merge conflicts

This commit is contained in:
zandercymatics 2024-03-13 12:23:40 -06:00
parent f6462d4ccc
commit 753e086701
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
2 changed files with 11 additions and 13 deletions

View file

@ -4,7 +4,7 @@ import logging
from django import forms from django import forms
from django.core.validators import MinValueValidator, MaxValueValidator, RegexValidator from django.core.validators import MinValueValidator, MaxValueValidator, RegexValidator
from django.forms import formset_factory from django.forms import formset_factory
from registrar.models import DomainApplication from registrar.models import DomainRequest
from phonenumber_field.widgets import RegionalPhoneNumberWidget from phonenumber_field.widgets import RegionalPhoneNumberWidget
from registrar.utility.errors import ( from registrar.utility.errors import (
NameserverError, NameserverError,
@ -280,8 +280,8 @@ class AuthorizingOfficialContactForm(ContactForm):
return super().save() return super().save()
# Determine if the domain is federal or tribal # Determine if the domain is federal or tribal
is_federal = self.domainInfo.organization_type == DomainApplication.OrganizationChoices.FEDERAL is_federal = self.domainInfo.organization_type == DomainRequest.OrganizationChoices.FEDERAL
is_tribal = self.domainInfo.organization_type == DomainApplication.OrganizationChoices.TRIBAL is_tribal = self.domainInfo.organization_type == DomainRequest.OrganizationChoices.TRIBAL
# Get the Contact object from the db for the Authorizing Official # Get the Contact object from the db for the Authorizing Official
db_ao = Contact.objects.get(id=self.instance.id) db_ao = Contact.objects.get(id=self.instance.id)
@ -381,26 +381,24 @@ class DomainOrgNameAddressForm(forms.ModelForm):
self.fields["state_territory"].widget.attrs.pop("maxlength", None) self.fields["state_territory"].widget.attrs.pop("maxlength", None)
self.fields["zipcode"].widget.attrs.pop("maxlength", None) self.fields["zipcode"].widget.attrs.pop("maxlength", None)
is_federal = self.instance.organization_type == DomainApplication.OrganizationChoices.FEDERAL self.is_federal = self.instance.organization_type == DomainRequest.OrganizationChoices.FEDERAL
is_tribal = self.instance.organization_type == DomainApplication.OrganizationChoices.TRIBAL self.is_tribal = self.instance.organization_type == DomainRequest.OrganizationChoices.TRIBAL
if is_federal: if self.is_federal:
self.fields["federal_agency"].disabled = True self.fields["federal_agency"].disabled = True
elif is_tribal: elif self.is_tribal:
self.fields["organization_name"].disabled = True self.fields["organization_name"].disabled = True
def save(self, commit=True): def save(self, commit=True):
"""Override the save() method of the BaseModelForm.""" """Override the save() method of the BaseModelForm."""
if self.has_changed(): if self.has_changed():
is_federal = self.instance.organization_type == DomainApplication.OrganizationChoices.FEDERAL
is_tribal = self.instance.organization_type == DomainApplication.OrganizationChoices.TRIBAL
# This action should be blocked by the UI, as the text fields are readonly. # This action should be blocked by the UI, as the text fields are readonly.
# If they get past this point, we forbid it this way. # If they get past this point, we forbid it this way.
# This could be malicious, so lets reserve information for the backend only. # This could be malicious, so lets reserve information for the backend only.
if is_federal and not self._field_unchanged("federal_agency"): if self.is_federal and not self._field_unchanged("federal_agency"):
raise ValueError("federal_agency cannot be modified when the organization_type is federal") raise ValueError("federal_agency cannot be modified when the organization_type is federal")
elif is_tribal and not self._field_unchanged("organization_name"): elif self.is_tribal and not self._field_unchanged("organization_name"):
raise ValueError("organization_name cannot be modified when the organization_type is tribal") raise ValueError("organization_name cannot be modified when the organization_type is tribal")
else: else:

View file

@ -18,7 +18,7 @@ from django.conf import settings
from registrar.models import ( from registrar.models import (
Domain, Domain,
DomainApplication, DomainRequest,
DomainInformation, DomainInformation,
DomainInvitation, DomainInvitation,
User, User,
@ -235,7 +235,7 @@ class DomainAuthorizingOfficialView(DomainFormBaseView):
form_kwargs["instance"] = self.object.domain_info.authorizing_official form_kwargs["instance"] = self.object.domain_info.authorizing_official
domain_info = self.get_domain_info_from_domain() domain_info = self.get_domain_info_from_domain()
invalid_fields = [DomainApplication.OrganizationChoices.FEDERAL, DomainApplication.OrganizationChoices.TRIBAL] invalid_fields = [DomainRequest.OrganizationChoices.FEDERAL, DomainRequest.OrganizationChoices.TRIBAL]
is_federal_or_tribal = domain_info and (domain_info.organization_type in invalid_fields) is_federal_or_tribal = domain_info and (domain_info.organization_type in invalid_fields)
form_kwargs["disable_fields"] = is_federal_or_tribal form_kwargs["disable_fields"] = is_federal_or_tribal