Skip to content

Commit

Permalink
Use RegistrantTypeChoices to populate form
Browse files Browse the repository at this point in the history
So we only have registrant types recorded in one place.
  • Loading branch information
jimnarey committed Mar 8, 2024
1 parent 3c6eb82 commit 7492fa9
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions request_a_govuk_domain/request/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
)

from .utils import organisations_list
from .models.organisation import RegistrantTypeChoices


class NameForm(forms.Form):
Expand Down Expand Up @@ -197,27 +198,14 @@ def __init__(self, *args, **kwargs):


class RegistrantTypeForm(forms.Form):
REGISTRANT_TYPES = (
Choice("central_gov", "Central government department or agency"),
Choice("alb", "Non-departmental body - also known as an arm's length body"),
Choice("fire_service", "Fire service"),
Choice("county_council", "County, borough, metropolitan or district council"),
Choice("parish_council", "Parish, town or community council"),
Choice("village_council", "Neighbourhood or village council"),
Choice("combined_authority", "Combined or unitary authority"),
Choice("pcc", "Police and crime commissioner"),
Choice("joint_authority", "Joint authority"),
Choice("joint_committee", "Joint committee"),
Choice(
"representing_public_sector",
"Representing public sector bodies",
divider="Or",
),
Choice("none", "None of the above"),
)
registrant_types = [
Choice(*item) for item in RegistrantTypeChoices.__members__.items()
]
registrant_types[-1].divider = "Or"
registrant_types.append(Choice("none", "None of the above"))

registrant_type = forms.ChoiceField(
choices=REGISTRANT_TYPES,
choices=registrant_types,
widget=forms.RadioSelect,
label="Your registrant must be from an eligible organisation to get a .gov.uk domain name.",
error_messages={"required": "Please select from one of the choices"},
Expand Down

0 comments on commit 7492fa9

Please sign in to comment.