Basic styling / HTML content

Needs some work, but this is fine for now
This commit is contained in:
zandercymatics 2024-03-05 14:52:25 -07:00
parent 20161fe7f6
commit 550bed1de6
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 54 additions and 2 deletions

View file

@ -38,3 +38,11 @@ legend.float-left-tablet + button.float-right-tablet {
margin-top: 1rem; margin-top: 1rem;
} }
} }
/* Custom style for disabled inputs */
// TODO - UPDATE THIS!
.usa-input:disabled, .usa-select:disabled, .usa-textarea:disabled {
background-color: #f0f0f0;
color: #5b616b;
border-color: #5b616b;
}

View file

@ -222,7 +222,7 @@ class AuthorizingOfficialContactForm(ContactForm):
JOIN = "authorizing_official" JOIN = "authorizing_official"
def __init__(self, *args, **kwargs): def __init__(self, disable_fields=False, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
# Overriding bc phone not required in this form # Overriding bc phone not required in this form
@ -243,6 +243,17 @@ class AuthorizingOfficialContactForm(ContactForm):
"required": "Enter an email address in the required format, like name@example.com." "required": "Enter an email address in the required format, like name@example.com."
} }
# TODO - uswds text fields dont have disabled styling??
# All fields should be disabled if the domain is federal or tribal
if disable_fields:
self._mass_disable_fields()
def _mass_disable_fields(self):
"""Given all available fields, invoke .disabled = True on them"""
for field in self.fields.values():
field.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.
@ -357,6 +368,20 @@ 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
is_tribal = self.instance.organization_type == DomainApplication.OrganizationChoices.TRIBAL
# (Q) Should required = False be set here?
# These fields should not be None. If they are,
# it seems like an analyst should intervene?
# TODO - maybe consider adding a modal on these fields on hover
# ALSO TODO - uswds text fields dont have disabled styling??
if is_federal:
self.fields['federal_agency'].disabled = True
elif is_tribal:
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():

View file

@ -12,6 +12,13 @@
<p>Your authorizing official is a person within your organization who can <p>Your authorizing official is a person within your organization who can
authorize domain requests. This person must be in a role of significant, executive responsibility within the organization. Read more about <a class="usa-link" rel="noopener noreferrer" target="_blank" href="{% public_site_url 'domains/eligibility/#you-must-have-approval-from-an-authorizing-official-within-your-organization' %}">who can serve as an authorizing official</a>.</p> authorize domain requests. This person must be in a role of significant, executive responsibility within the organization. Read more about <a class="usa-link" rel="noopener noreferrer" target="_blank" href="{% public_site_url 'domains/eligibility/#you-must-have-approval-from-an-authorizing-official-within-your-organization' %}">who can serve as an authorizing official</a>.</p>
{% if organization_type == "federal" or organization_type == "tribal" %}
<p>
The authorizing official for your organization cant be updated here.
To suggest an update, email <a href="mailto:help@get.gov" class="usa-link">help@get.gov</a>.
</p>
{% endif %}
{% include "includes/required_fields.html" %} {% include "includes/required_fields.html" %}
<form class="usa-form usa-form--large" method="post" novalidate id="form-container"> <form class="usa-form usa-form--large" method="post" novalidate id="form-container">

View file

@ -233,8 +233,20 @@ class DomainAuthorizingOfficialView(DomainFormBaseView):
"""Add domain_info.authorizing_official instance to make a bound form.""" """Add domain_info.authorizing_official instance to make a bound form."""
form_kwargs = super().get_form_kwargs(*args, **kwargs) form_kwargs = super().get_form_kwargs(*args, **kwargs)
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()
invalid_fields = [DomainApplication.OrganizationChoices.FEDERAL, DomainApplication.OrganizationChoices.TRIBAL]
is_federal_or_tribal = domain_info and (domain_info.organization_type in invalid_fields)
form_kwargs["disable_fields"] = is_federal_or_tribal
return form_kwargs return form_kwargs
def get_context_data(self, **kwargs):
"""Adds custom context."""
context = super().get_context_data(**kwargs)
context["organization_type"] = self.object.domain_info.organization_type
return context
def get_success_url(self): def get_success_url(self):
"""Redirect to the overview page for the domain.""" """Redirect to the overview page for the domain."""
return reverse("domain-authorizing-official", kwargs={"pk": self.object.pk}) return reverse("domain-authorizing-official", kwargs={"pk": self.object.pk})