def party_address_form(request, title, button, is_gb_excluded=False): return Form( title=title, questions=[ TextArea("address", "Address"), country_question( countries=get_countries(request, True, ["GB"]) if is_gb_excluded else get_countries(request, True), prefix="", ), ], default_button_name=button, )
def new_location_form(request, application_type, location_type): exclude = [] if application_type in [CaseTypes.SITL, CaseTypes.SICL, CaseTypes.OICL]: exclude.append("GB") countries = get_countries(request, True, exclude) return Form( title=NewLocationForm.TITLE, description=NewLocationForm.DESCRIPTION, questions=[ HiddenField(name="external_locations", value=""), TextInput(name="name", title=NewLocationForm.Name.TITLE), TextArea( name="address", title=conditional( location_type == LocationType.SEA_BASED, NewLocationForm.Address.SEA_BASED_TITLE, NewLocationForm.Address.TITLE, ), description=conditional( application_type == CaseTypes.SITL, NewLocationForm.Address.SITL_DESCRIPTION, conditional( location_type == LocationType.SEA_BASED, NewLocationForm.Address.SEA_BASED_DESCRIPTION, NewLocationForm.Address.DESCRIPTION, ), ), ), conditional(location_type != LocationType.SEA_BASED, country_question(prefix="", countries=countries)), ], default_button_name=strings.SAVE_AND_CONTINUE, )
def countries_form(request, application_id): return Form( title=strings.applications.DestinationForm.TITLE, description=strings.applications.DestinationForm.DESCRIPTION, questions=[ Filter(), Checkboxes( name="countries[]", options=get_countries(request, True, ["GB"]), classes=["govuk-checkboxes--small"], show_select_links=True, filterable=True, ), ], default_button_name=strings.SAVE_AND_CONTINUE, back_link=back_to_task_list(application_id), )
def site_form(request, is_individual, location): from exporter.core.views import RegisterAnOrganisationTriage is_in_uk = location == RegisterAnOrganisationTriage.Locations.UNITED_KINGDOM return Form( title=conditional( not is_individual, conditional( is_in_uk, RegisterAnOrganisation.Headquarters.TITLE, RegisterAnOrganisation.Headquarters.TITLE_FOREIGN, ), conditional( is_in_uk, RegisterAnOrganisation.Headquarters.TITLE_INDIVIDUAL, RegisterAnOrganisation.Headquarters.TITLE_INDIVIDUAL_FOREIGN, ), ), description=RegisterAnOrganisation.Headquarters.DESCRIPTION, caption="Step 4 of 4", questions=[ TextInput( title=RegisterAnOrganisation.Headquarters.NAME, description=RegisterAnOrganisation.Headquarters. NAME_DESCRIPTION, name="site.name", ), *conditional( is_in_uk, address_questions(None, is_individual, "site.address."), foreign_address_questions(is_individual, get_countries(request, True, ["GB"]), "site.address."), ), ], default_button_name=generic.CONTINUE, )
def apply_for_an_end_user_advisory_form(request, individual, commercial): return FormGroup( [ Form( title="Confirm how the products will be used", questions=[ HTMLBlock( "<ul class='govuk-list govuk-list--bullet'>" "<li class='govuk-!-margin-bottom-5'>I've checked the <a class='govuk-link' href='https://scsanctions.un.org/fop/fop?xml=htdocs/resources/xml/en/consolidated.xml&xslt=htdocs/resources/xsl/en/consolidated.xsl'>UN Security Council Committee's list</a> and the products will not be used by anyone named on this list</li>" # noqa "<li class='govuk-!-margin-bottom-5'>I've checked the <a class='govuk-link' href='https://permissions-finder.service.trade.gov.uk/'>Department for International Trade's list of controlled goods</a> and the products are not controlled</li>" # noqa "<li class='govuk-!-margin-bottom-5'>I've previously not been informed by the Export Control Joint Unit (ECJU) that the products could be used to make chemical, biological or nuclear weapons</li>" # noqa "<li>I do not have any reason to suspect that the products could be used to make chemical, biological or nuclear weapons</li>" # noqa "</ul>"), ], default_button_name="Confirm and continue", ), Form( title="Select the type of end user", questions=[ RadioButtons( title="", name="end_user.sub_type", options=[ Option("government", "Government organisation"), Option("commercial", "Commercial organisation"), Option("individual", "An individual"), Option("other", "Other", show_or=True), ], ), ], default_button_name="Continue", ), Form( title="End user details", questions=[ TextInput(title="Organisation name", name="end_user.name"), conditional( individual, TextInput(title="Email address", name="contact_email")), conditional( individual, TextInput(title="Telephone number", name="contact_telephone")), conditional( commercial, TextInput(title="Nature of the end user's business", name="nature_of_business"), ), conditional( not individual, TextInput(title="Contact's name", name="contact_name")), conditional( not individual, TextInput(title="Job title", name="contact_job_title"), ), conditional( not individual, TextInput(title="Email address", name="contact_email"), ), conditional( not individual, TextInput(title="Telephone number", name="contact_telephone"), ), TextInput(title="Website address", name="end_user.website", optional=True), TextArea( title="Address", description= "The delivery address or registered office for the person " "receiving the products.", name="end_user.address", ), country_question(countries=get_countries(request, True), prefix="end_user."), HiddenField("validate_only", True), ], default_button_name="Continue", ), Form( title="More information about the end user", questions=[ TextArea( title="What's your reasoning behind this query?", optional=True, name="reasoning", extras={"max_length": 2000}, ), TextArea( title= "Is there any other information you can provide about the end user?", description= "This may help provide a quicker response from ECJU.", optional=True, name="note", extras={"max_length": 2000}, ), HiddenField("validate_only", False), ], ), ], show_progress_indicators=True, )
def copy_end_user_advisory_form(request, individual, commercial): return FormGroup([ Form( title="End user details", questions=[ TextInput(title="Organisation name", name="end_user.name"), conditional( individual, TextInput(title="Email address", name="contact_email")), conditional( individual, TextInput(title="Telephone number", name="contact_telephone")), conditional( commercial, TextInput(title="Nature of the end user's business", name="nature_of_business"), ), conditional( not individual, TextInput(title="Contact's name", name="contact_name")), conditional( not individual, TextInput(title="Job title", name="contact_job_title"), ), conditional( not individual, TextInput(title="Email address", name="contact_email"), ), conditional( not individual, TextInput(title="Telephone number", name="contact_telephone"), ), TextInput(title="Website address", name="end_user.website", optional=True), TextArea( title="Address", description= "The delivery address or registered office for the person " "receiving the products", name="end_user.address", ), country_question(countries=get_countries(request, True), prefix="end_user."), HiddenField("validate_only", True), ], back_link=BackLink( strings.end_users.CopyEndUserAdvisoryForm.BACK_LINK, reverse_lazy("end_users:end_users")), default_button_name=strings.CONTINUE, ), Form( title="More information about the end user", questions=[ TextArea( title="What's your reasoning behind this query?", optional=True, name="reasoning", extras={ "max_length": 2000, }, ), TextArea( title= "Is there any other information you can provide about the end user?", description= "This may help provide a quicker response from ECJU.", optional=True, name="note", extras={"max_length": 2000}, ), HiddenField("validate_only", False), ], ), ])
def countries(self): return get_countries(self.request, convert_to_options=True)
def new_site_forms(request): is_individual = request.POST.get("type") == "individual" in_uk = request.POST.get("location", "").lower() == "united_kingdom" sites = [] if request.POST.get("address.postcode"): sites = get_sites(request, request.session["organisation"], postcode=request.POST.get("address.postcode", "")) return FormGroup([ Form( caption="Step 1 of 4", title=AddSiteForm.WhereIsYourSiteBased.TITLE, description=AddSiteForm.WhereIsYourSiteBased.DESCRIPTION, questions=[ RadioButtons( name="location", options=[ Option( key="united_kingdom", value=AddSiteForm.WhereIsYourSiteBased.IN_THE_UK, description=AddSiteForm.WhereIsYourSiteBased. IN_THE_UK_DESCRIPTION, ), Option( key="abroad", value=AddSiteForm.WhereIsYourSiteBased. OUTSIDE_THE_UK, description=AddSiteForm.WhereIsYourSiteBased. OUTSIDE_THE_UK_DESCRIPTION, ), ], ) ], default_button_name=generic.CONTINUE, back_link=BackLink(AddSiteForm.BACK_LINK, reverse_lazy("organisation:sites:sites")), ), Form( caption="Step 2 of 4", title=AddSiteForm.Details.TITLE, description=AddSiteForm.Details.DESCRIPTION, questions=[ TextInput(title=AddSiteForm.Details.NAME, name="name"), Heading( conditional(in_uk, AddSiteForm.Details.ADDRESS_HEADER_UK, AddSiteForm.Details.ADDRESS_HEADER_ABROAD), HeadingStyle.M, ), *conditional( in_uk, address_questions(None, is_individual), foreign_address_questions( is_individual, get_countries(request, True, ["GB"])), ), HiddenField("validate_only", True), ], default_button_name=generic.CONTINUE, ), conditional( sites, Form( title=AddSiteForm.Postcode.TITLE, description=AddSiteForm.Postcode.DESCRIPTION.format(", ".join( site["name"] for site in sites)), questions=[ HiddenField(name="are_you_sure", value=None), RadioButtons( name="are_you_sure", title=AddSiteForm.Postcode.CONTROL_TITLE, options=[ Option(True, AddSiteForm.Postcode.YES), Option(False, AddSiteForm.Postcode.NO), ], ), ], default_button_name=generic.CONTINUE, ), ), site_records_location(request, in_uk), Form( caption="Step 4 of 4", title=AddSiteForm.AssignUsers.TITLE, description=AddSiteForm.AssignUsers.DESCRIPTION, questions=[ Filter(placeholder=AddSiteForm.AssignUsers.FILTER), Checkboxes( name="users[]", options=get_organisation_users( request, request.session["organisation"], { "disable_pagination": True, "exclude_permission": Permissions.ADMINISTER_SITES }, True, ), filterable=True, ), HiddenField("validate_only", False), ], default_button_name=generic.SAVE_AND_CONTINUE, ), ])
def open_general_licence_forms(request, **kwargs): open_general_licence_type = OpenGeneralExportLicenceTypes.get_by_acronym( kwargs["ogl"]) control_list_entries = get_control_list_entries(request, True) countries = get_countries(request, True) selected_entry = request.POST.get("control_list_entry") selected_country = next((country.value for country in countries if country.key == request.POST.get("country")), "") open_general_licences = get_open_general_licences( request, convert_to_options=True, case_type=open_general_licence_type.id, control_list_entry=request.POST.get("control_list_entry"), country=request.POST.get("country"), status="active", ) sites = get_sites(request, request.session["organisation"], True) selected_open_general_licence = {} if request.POST.get("open_general_licence"): selected_open_general_licence = get_open_general_licence( request, request.POST.get("open_general_licence")) if open_general_licence_type.acronym == OpenGeneralExportLicenceTypes.open_general_export_licence.acronym: back_link_url = reverse("apply_for_a_licence:export_licence_questions") elif open_general_licence_type.acronym == OpenGeneralExportLicenceTypes.open_general_transhipment_licence.acronym: back_link_url = reverse("apply_for_a_licence:transhipment_questions") else: back_link_url = reverse( "apply_for_a_licence:trade_control_licence_questions") return FormGroup([ Form( title=OpenGeneralLicenceQuestions.ControlListEntry.TITLE, description=OpenGeneralLicenceQuestions.ControlListEntry. DESCRIPTION, questions=[ AutocompleteInput(name="control_list_entry", options=control_list_entries) ], default_button_name=generic.CONTINUE, back_link=BackLink(url=back_link_url), ), Form( title=OpenGeneralLicenceQuestions.Country.TITLE, description=OpenGeneralLicenceQuestions.Country.DESCRIPTION, questions=[AutocompleteInput(name="country", options=countries)], default_button_name=generic.CONTINUE, ), *conditional( open_general_licences, [ Form( title=OpenGeneralLicenceQuestions.OpenGeneralLicences. TITLE.format(open_general_licence_type.name.lower()), questions=[ Label( OpenGeneralLicenceQuestions.OpenGeneralLicences. DESCRIPTION.format( open_general_licence_type.name.lower(), selected_entry, selected_country)), Label(OpenGeneralLicenceQuestions.OpenGeneralLicences. HELP_TEXT), RadioButtons( name="open_general_licence", options=[ *open_general_licences, Option( "", OpenGeneralLicenceQuestions. OpenGeneralLicences.NONE_OF_THE_ABOVE, show_or=True, ), ], ), ], default_button_name=generic.CONTINUE, ) ], [ no_open_general_licence_form(open_general_licence_type, selected_entry, selected_country) ], ), conditional( selected_open_general_licence, Form( caption=conditional( selected_open_general_licence.get("registration_required"), OpenGeneralLicenceQuestions.OpenGeneralLicenceDetail. CAPTION, ), title=open_general_licence_type.name + " (" + selected_open_general_licence.get("name", "") + ")", questions=[ conditional( not selected_open_general_licence.get( "registration_required"), WarningBanner( "warning", OpenGeneralLicenceQuestions. OpenGeneralLicenceDetail.NO_REGISTRATION_REQUIRED. format(open_general_licence_type.name.lower()), ), ), HiddenField("application_type", open_general_licence_type.acronym.lower()), *conditional( selected_open_general_licence.get( "registration_required"), [ Heading( OpenGeneralLicenceQuestions. OpenGeneralLicenceDetail.Summary.HEADING, HeadingStyle.S), Custom( "components/ogl-step-list.html", data={ **selected_open_general_licence, "sites": sites }, ), Custom("components/ogl-warning.html"), Checkboxes( name="confirmation[]", options=[ Option( "read", OpenGeneralLicenceQuestions. Conditions.READ), Option( "comply", OpenGeneralLicenceQuestions. Conditions.COMPLY), ], ), ], [], ), ], buttons=[ conditional( selected_open_general_licence.get( "registration_required"), Button("Register", "submit"), ) ], ), no_open_general_licence_form(open_general_licence_type, selected_entry, selected_country), ), ])