Add readonly mode

This commit is contained in:
zandercymatics 2024-07-23 13:50:50 -06:00
parent 7f36e6270c
commit a5a061335e
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
4 changed files with 26 additions and 4 deletions

View file

@ -508,6 +508,7 @@ class DomainOrgNameAddressForm(forms.ModelForm):
return old_value == new_value
# TODO: Will be refined in #2352
class DomainSuborganizationForm(forms.ModelForm):
"""Form for updating the suborganization"""
@ -536,6 +537,9 @@ class DomainSuborganizationForm(forms.ModelForm):
# Use the combobox rather than the regular select widget
self.fields['sub_organization'].widget.template_name = "django/forms/widgets/combobox.html"
# TODO: Remove in #2352
DomainHelper.disable_field(self.fields['sub_organization'], disable_required=True)
class DomainDnssecForm(forms.Form):

View file

@ -15,11 +15,16 @@
If you believe there is an error please contact <a href="mailto:help@get.gov" class="usa-link">help@get.gov</a>.
</p>
{% include "includes/required_fields.html" %}
{% if suborganization_is_editable %}
{% include "includes/required_fields.html" %}
{% endif %}
<form class="usa-form usa-form--large" method="post" novalidate id="form-container">
{% csrf_token %}
{% input_with_errors form.sub_organization %}
<button type="submit" class="usa-button">Save</button>
{% if suborganization_is_editable %}
<button type="submit" class="usa-button">Save</button>
{% endif %}
</form>
{% endblock %}

View file

@ -67,8 +67,10 @@ error messages, if necessary.
{% include "includes/readonly_input.html" %}
{% endif %}
{# this is the input field, itself #}
{% include widget.template_name %}
{# this is the input field, itself. Toggleable because of the show_readonly flag. #}
{% if not remove_input_field %}
{% include widget.template_name %}
{% endif %}
{% if append_gov %}
<span class="padding-top-05 padding-left-2px">.gov </span>

View file

@ -26,6 +26,7 @@ from registrar.models import (
UserDomainRole,
)
from registrar.models.public_contact import PublicContact
from registrar.models.utility.domain_helper import DomainHelper
from registrar.utility.enums import DefaultEmail
from registrar.utility.errors import (
GenericError,
@ -222,6 +223,7 @@ class DomainOrgNameAddressView(DomainFormBaseView):
return super().form_valid(form)
# TODO: Edit will be added in #2352
class DomainSubOrganizationView(DomainFormBaseView):
"""Suborganization view"""
@ -249,6 +251,15 @@ class DomainSubOrganizationView(DomainFormBaseView):
# superclass has the redirect
return super().form_valid(form)
def get_context_data(self, **kwargs):
"""Adds custom context."""
context = super().get_context_data(**kwargs)
# TODO: Switch to True #2352
suborganization_is_editable = False
context["suborganization_is_editable"] = suborganization_is_editable
return context
class DomainSeniorOfficialView(DomainFormBaseView):
"""Domain senior official editing view."""