Review feedback: more required instructions

This commit is contained in:
Neil Martinsen-Burrell 2023-01-06 13:32:26 -06:00
parent 29d8f4b23d
commit beb9a298d4
No known key found for this signature in database
GPG key ID: 6A3C818CC10D0184
5 changed files with 39 additions and 8 deletions

View file

@ -101,9 +101,10 @@ class OrganizationContactForm(RegistrarForm):
federal_agency = forms.ChoiceField( federal_agency = forms.ChoiceField(
label="Federal agency", label="Federal agency",
# not required because this field won't be filled out unless # not required because this field won't be filled out unless
# it is a federal agency. # it is a federal agency. Use clean to check programatically
# if it has been filled in when required.
required=False, required=False,
choices=DomainApplication.AGENCY_CHOICES, choices=[("", "--Select--")] + DomainApplication.AGENCY_CHOICES,
label_suffix=REQUIRED_SUFFIX, label_suffix=REQUIRED_SUFFIX,
) )
organization_name = forms.CharField( organization_name = forms.CharField(
@ -138,6 +139,18 @@ class OrganizationContactForm(RegistrarForm):
label="Urbanization (Puerto Rico only)", label="Urbanization (Puerto Rico only)",
) )
def clean_federal_agency(self):
"""Require something to be selected when this is a federal agency."""
federal_agency = self.cleaned_data.get("federal_agency", None)
# need the wizard object to know if this is federal
context = self.get_context()
print(context)
if wizard._is_federal():
if not federal_agency:
# no answer was selected
raise forms.ValidationError("Please select your federal agency.", code="required")
return federal_agency
class AuthorizingOfficialForm(RegistrarForm): class AuthorizingOfficialForm(RegistrarForm):
def to_database(self, obj): def to_database(self, obj):

View file

@ -21,16 +21,16 @@
{% include "includes/domain_example__city.html" %} {% include "includes/domain_example__city.html" %}
</div> </div>
<form id="step__{{wizard.steps.current}}" class="usa-form usa-form--large" method="post"> <form id="step__{{wizard.steps.current}}" class="usa-form usa-form--large" method="post" novalidate>
<h2> What .gov domain do you want? </h2> <h2> What .gov domain do you want? </h2>
<p class="domain_instructions"> After you enter your domain, well make sure its available and that it meets some of our naming requirements. If your domain passes these initial checks, well verify that it meets all of our requirements once you complete and submit the rest of this form. </p> <p class="domain_instructions"> After you enter your domain, well make sure its available and that it meets some of our naming requirements. If your domain passes these initial checks, well verify that it meets all of our requirements once you complete and submit the rest of this form. </p>
<p> This question is required. </p>
{{ wizard.management_form }} {{ wizard.management_form }}
{% csrf_token %} {% csrf_token %}
{% if wizard.form.requested_domain.errors %} {% if wizard.form.requested_domain.errors %}
<div class="usa-form-group usa-form-group--error"> <div class="usa-form-group usa-form-group--error">
{{ wizard.form.requested_domain|add_label_class:"usa-label usa-label--error" }}
{% for error in wizard.form.requested_domain.errors %} {% for error in wizard.form.requested_domain.errors %}
<span class="usa-error-message" id="input-error-message" role="alert"> <span class="usa-error-message" id="input-error-message" role="alert">
{{ error }} {{ error }}
@ -43,7 +43,6 @@
</div> </div>
</div> </div>
{% else %} {% else %}
{{ wizard.form.requested_domain|add_label_class:"usa-label" }}
<div class="display-flex flex-align-center"> <div class="display-flex flex-align-center">
<span class="padding-top-05 padding-right-2px">www.</span> <span class="padding-top-05 padding-right-2px">www.</span>
{{ wizard.form.requested_domain|add_class:"usa-input"|attr:"aria-describedby:domain_instructions" }} {{ wizard.form.requested_domain|add_class:"usa-input"|attr:"aria-describedby:domain_instructions" }}

View file

@ -10,7 +10,8 @@
{% csrf_token %} {% csrf_token %}
<fieldset id="federal_type__fieldset" class="usa-fieldset"> <fieldset id="federal_type__fieldset" class="usa-fieldset">
<legend> <legend>
<h2 class="margin-bottom-5">Which federal branch is your organization in?</h2> <h2>Which federal branch is your organization in?</h2>
<p class="margin-bottom-5">This question is required.</p>
</legend> </legend>
{% radio_buttons_by_value wizard.form.federal_type as choices %} {% radio_buttons_by_value wizard.form.federal_type as choices %}
{% for choice in choices.values %} {% for choice in choices.values %}

View file

@ -8,14 +8,30 @@
<p id="instructions">Describe the reason for your domain request. Explain how you plan to use this domain. Will you use it for a website and/or email? Are you moving your website from another top-level domain (like .com or .org)? Read about <a href="#">activities that are prohibited on .gov domains.</a></p> <p id="instructions">Describe the reason for your domain request. Explain how you plan to use this domain. Will you use it for a website and/or email? Are you moving your website from another top-level domain (like .com or .org)? Read about <a href="#">activities that are prohibited on .gov domains.</a></p>
<p> This question is required. </p>
<form id="step__{{wizard.steps.current}}" class="usa-form usa-form--large" method="post" novalidate> <form id="step__{{wizard.steps.current}}" class="usa-form usa-form--large" method="post" novalidate>
<div class="usa-form-group"> <div class="usa-form-group">
{{ wizard.management_form }} {{ wizard.management_form }}
{% csrf_token %} {% csrf_token %}
<div class="usa-character-count"> <div class="usa-character-count">
{{ wizard.form.purpose|add_label_class:"usa-label usa-sr-only" }} {% with field=wizard.form.purpose %}
{{ wizard.form.purpose|add_class:"usa-textarea usa-character-count__field"|attr:"aria-describedby:instructions"|attr:"maxlength=500" }} {% if field.errors %}
<div class="usa-form-group usa-form-group--error">
{{ field|add_label_class:"usa-label usa-label--error usa-sr-only" }}
{% for error in field.errors %}
<span class="usa-error-message" id="input-error-message" role="alert">
{{ error }}
</span>
{% endfor %}
{{ field|add_class:"usa-input--error usa-textarea usa-character-count__field"|attr:"aria-describedby:instructions"|attr:"maxlength=500"|attr:"aria-invalid:true" }}
</div>
{% else %}
{{ field|add_label_class:"usa-label usa-sr-only" }}
{{ field|add_class:"usa-textarea usa-character-count__field"|attr:"aria-describedby:instructions"|attr:"maxlength=500" }}
{% endif %}
{% endwith %}
<span class="usa-character-count__message" id="with-hint-textarea-info with-hint-textarea-hint"> You can enter up to 500 characters </span> <span class="usa-character-count__message" id="with-hint-textarea-info with-hint-textarea-hint"> You can enter up to 500 characters </span>
</div> </div>
</div> </div>

View file

@ -127,6 +127,8 @@
<h2>Acknowledgement of .gov domain requirements</h2> <h2>Acknowledgement of .gov domain requirements</h2>
<p>This question is required.</p>
<form id="step__{{wizard.steps.current}}" class="usa-form usa-form--large" method="post" novalidate> <form id="step__{{wizard.steps.current}}" class="usa-form usa-form--large" method="post" novalidate>
<div class="usa-form-group"> <div class="usa-form-group">
{{ wizard.management_form }} {{ wizard.management_form }}