def generate_activity_filters(activity_filters, string_class): def make_options(values): return [Option(option["key"], option["value"]) for option in values] return FiltersBar( [ Select( title=string_class.ActivityFilters.USER, name="user_id", options=make_options(activity_filters["users"]), ), Select( title=string_class.ActivityFilters.TEAM, name="team_id", options=make_options(activity_filters["teams"]), ), Select( title=string_class.ActivityFilters.USER_TYPE, name="user_type", options=make_options(activity_filters["user_types"]), ), Select( title=string_class.ActivityFilters.ACTIVITY_TYPE, name="activity_type", options=make_options(activity_filters["activity_types"]), ), DateInput(title=string_class.ActivityFilters.DATE_FROM, prefix="from_", inline_title=True), DateInput(title=string_class.ActivityFilters.DATE_TO, prefix="to_", inline_title=True), ] )
def exhibition_details_form(application_id): return Form( title=strings.Exhibition.EXHIBITION_TITLE, questions=[ TextInput(title=strings.Exhibition.TITLE, name="title"), DateInput( title=strings.Exhibition.FIRST_EXHIBITION_DATE, description=strings.Exhibition.DATE_DESCRIPTION, prefix="first_exhibition_date", name="first_exhibition_date", ), DateInput( title=strings.Exhibition.REQUIRED_BY_DATE, description=strings.Exhibition.DATE_DESCRIPTION, prefix="required_by_date", name="required_by_date", ), TextArea( title=strings.Exhibition.REASON_FOR_CLEARANCE, name="reason_for_clearance", optional=True, extras={"max_length": 2000}, ), ], back_link=BackLink( strings.BACK_TO_APPLICATION, reverse_lazy("applications:task_list", kwargs={"pk": application_id}), ), )
def upload_firearms_act_certificate_form(section, filename, back_link): return Form( title=f"Attach your Firearms Act 1968 {section} certificate", description="The file must be smaller than 50MB", questions=[ HiddenField("firearms_certificate_uploaded", False), FileUpload(), HiddenField("uploaded_file_name", filename), TextInput( title=CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_CERTIFICATE_NUMBER, description="", name="section_certificate_number", optional=False, ), DateInput( title=CreateGoodForm.FirearmGood.FirearmsActCertificate.EXPIRY_DATE, description=CreateGoodForm.FirearmGood.FirearmsActCertificate.EXPIRY_DATE_HINT, prefix="section_certificate_date_of_expiry", name="section_certificate_date_of_expiry", ), Label(text="Or"), Checkboxes( name="section_certificate_missing", options=[Option(key="True", value=f"I do not have a Firearms Act 1968 {section} certificate",)], ), TextArea( title="Provide a reason why you do not have a certificate", name="section_certificate_missing_reason", optional=False, ), ], back_link=back_link, buttons=[Button("Save and continue", "submit")], javascript_imports={"/javascripts/add-good.js"}, )
def pv_details_form(request): return Form( title=GoodGradingForm.TITLE, description=GoodGradingForm.DESCRIPTION, questions=[ Heading("PV grading", HeadingStyle.M), Group( components=[ TextInput(title=GoodGradingForm.PREFIX, name="prefix", optional=True), Select( options=get_pv_gradings(request, convert_to_options=True), title=GoodGradingForm.GRADING, name="grading", optional=True, ), TextInput(title=GoodGradingForm.SUFFIX, name="suffix", optional=True), ], classes=["app-pv-grading-inputs"], ), TextInput(title=GoodGradingForm.OTHER_GRADING, name="custom_grading", optional=True), TextInput(title=GoodGradingForm.ISSUING_AUTHORITY, name="issuing_authority"), TextInput(title=GoodGradingForm.REFERENCE, name="reference"), DateInput( title=GoodGradingForm.DATE_OF_ISSUE, prefix="date_of_issue", name="date_of_issue", optional=False ), ], default_button_name=GoodGradingForm.BUTTON, )
def approve_licence_form(queue_pk, case_id, is_open_licence, editable_duration, goods, goods_html): return Form( title=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.APPROVE_TITLE, questions=[ DateInput( description=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.DATE_DESCRIPTION, title=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.DATE_TITLE, prefix="", ), conditional( editable_duration, TextInput( title=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.DURATION_TITLE, name="duration", description=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.DURATION_DESCRIPTION, ), ), HiddenField(name="action", value="approve"), conditional(goods, Custom(goods_html, data=goods,)), ], container="case", back_link=conditional( is_open_licence, BackLink( url=reverse_lazy("cases:finalise_goods_countries", kwargs={"queue_pk": queue_pk, "pk": case_id}), text=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.Actions.BACK_TO_DECISION_MATRIX_BUTTON, ), BackLink( url=reverse_lazy("cases:case", kwargs={"queue_pk": queue_pk, "pk": case_id, "tab": "final-advice"}), text=lite_content.lite_internal_frontend.advice.FinaliseLicenceForm.Actions.BACK_TO_ADVICE_BUTTON, ), ), )
def set_next_review_date_form(queue_id, case_id): return Form( title=cases.Manage.SetNextReviewDate.TITLE, description=cases.Manage.SetNextReviewDate.DESCRIPTION, questions=[DateInput(prefix="next_review_date", name="next_review_date")], buttons=[Button("Continue", action="submit")], back_link=BackLink(url=reverse("cases:case", kwargs={"queue_pk": queue_id, "pk": case_id, "tab": "details"})), )
def firearms_act_confirmation_form(): return Form( title=CreateGoodForm.FirearmGood.FirearmsActCertificate.TITLE, questions=[ HiddenField("section_certificate_step", True), Label(CreateGoodForm.FirearmGood.FirearmsActCertificate.FIREARMS_ACT), Label( id="section-1-link", text=linkify( CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_ONE_LINK, name=CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_ONE, ), ), Label( id="section-2-link", text=linkify( CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_TWO_LINK, name=CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_TWO, ), ), Label( id="section-5-link", text=linkify( CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_FIVE_LINK, name=CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_FIVE, ), ), RadioButtons( title="", name="is_covered_by_firearm_act_section_one_two_or_five", options=[ Option( key=True, value=CreateGoodForm.FirearmGood.FirearmsActCertificate.YES, components=[ TextInput( title=CreateGoodForm.FirearmGood.FirearmsActCertificate.SECTION_CERTIFICATE_NUMBER, description="", name="section_certificate_number", optional=False, ), DateInput( title=CreateGoodForm.FirearmGood.FirearmsActCertificate.EXPIRY_DATE, description=CreateGoodForm.FirearmGood.FirearmsActCertificate.EXPIRY_DATE_HINT, prefix="section_certificate_date_of_expiry", name="section_certificate_date_of_expiry", ), ], ), Option(key=False, value=CreateGoodForm.FirearmGood.FirearmsActCertificate.NO), ], ), ], )
def firearm_is_deactivated_field(): return RadioButtons( title="Has the product been deactivated?", name="is_deactivated", options=[ Option( key=True, value="Yes", components=[ DateInput( title="Date of deactivation", name="date_of_deactivation", prefix="date_of_deactivation", ), RadioButtons( title= "Has the product been deactivated to UK/EU proof house standards?", name="is_deactivated_to_standard", options=[ Option( key=True, value="Yes", components=[ Select( title="Proof house standard", name="deactivation_standard", options=[ Option(key="UK", value="UK"), Option(key="EU", value="EU"), ], ), ], ), Option( key=False, value="No", components=[ TextArea( title= "Describe who deactivated the product and to what standard it was done", description="", name="deactivation_standard_other", optional=False, ), ], ), ], ), ], ), Option(key=False, value="No"), ], )
def attach_firearm_dealer_certificate_form(back_url): return Form( title="Attach your registered firearms dealer certificate", description="The file must be smaller than 50MB", questions=[ FileUpload(), TextInput(name="reference_code", title="Certificate number",), DateInput( prefix="expiry_date_", name="expiry_date", title="Expiry date", description="For example 12 3 2021" ), ], back_link=BackLink("Back", back_url), )
def proposed_product_return_date_form(caption): return Form( caption=caption, title=TemporaryExportDetails.PROPOSED_RETURN_DATE, questions=[ DateInput( title="", short_title=TemporaryExportDetails.SummaryList.PROPOSED_RETURN_DATE, description=TemporaryExportDetails.PROPOSED_DATE_HINT, name="proposed_return_date", prefix="", optional=False, ), ], default_button_name=generic.SAVE_AND_CONTINUE, )
def visit_report_form(queue_pk, pk): return Form( title=ComplianceForms.VisitReport.TITLE, questions=[ Select(title=ComplianceForms.VisitReport.VISIT_TYPE, name="visit_type", options=Visit_type_choices), DateInput( title=ComplianceForms.VisitReport.VISIT_DATE, description=ComplianceForms.VisitReport.VISIT_DATE_DESCRIPTION, name="visit_date", prefix="visit_date_", ), Select(title=ComplianceForms.VisitReport.OVERALL_RISK_VALUE, name="overall_risk_value", options=risk_value), Select( title=ComplianceForms.VisitReport.LICENCE_RISK_VALUE, name="licence_risk_value", options=licence_risk_value, ), ], back_link=BackLink(url=reverse("cases:case", kwargs={"queue_pk": queue_pk, "pk": pk, "tab": "details"})), )
def expedited_form(): return Form( caption=F680Questions.CAPTION, title=F680Questions.Expedited.TITLE, questions=[ RadioButtons( name="expedited", options=[ Option( key=True, value="Yes", components=[ DateInput(title=F680Questions.Expedited.DATE, name="expedited_date", prefix=""), ], ), Option(key=False, value="No"), ], ) ], default_button_name=generic.SAVE_AND_CONTINUE, )
def case_filters_bar(request, queue) -> FiltersBar: """ Returns a FiltersBar for the case search page. """ sla_sort = [ Option("ascending", CasesListPage.Filters.SORT_BY_SLA_ELAPSED_ASCENDING), Option("descending", CasesListPage.Filters.SORT_BY_SLA_ELAPSED_DESCDENDING), ] sla_days = [Option(i, i) for i in range(SLA_DAYS_RANGE)] return FiltersBar( [ TextInput(name="case_reference", title="case reference"), Select(name="case_type", title=CasesListPage.Filters.CASE_TYPE, options=[]), Select(name="status", title=CasesListPage.Filters.CASE_STATUS, options=[]), AutocompleteInput( name="case_officer", title=CasesListPage.Filters.CASE_OFFICER, options=[ Option("not_assigned", CasesListPage.Filters.NOT_ASSIGNED) ], deferred=True, ), AutocompleteInput( name="assigned_user", title=CasesListPage.Filters.ASSIGNED_USER, options=[ Option("not_assigned", CasesListPage.Filters.NOT_ASSIGNED) ], deferred=True, ), conditional( not queue["is_system_queue"], Checkboxes( name="hidden", options=[ Option(True, CasesListPage.Filters.HIDDEN, id="show-hidden-cases") ], classes=["govuk-checkboxes--small"], ), ), ], advanced_filters=[ TextInput( name="exporter_application_reference", title=CasesListPage.Filters.EXPORTER_APPLICATION_REFERENCE), TextInput(name="organisation_name", title=CasesListPage.Filters.ORGANISATION_NAME), TextInput(name="exporter_site_name", title=CasesListPage.Filters.EXPORTER_SITE_NAME), TextInput(name="exporter_site_address", title=CasesListPage.Filters.EXPORTER_SITE_ADDRESS), Select(name="team_advice_type", title=CasesListPage.Filters.TEAM_ADVICE_TYPE, options=[]), Select(name="final_advice_type", title=CasesListPage.Filters.FINAL_ADVICE_TYPE, options=[]), Select(name="max_sla_days_remaining", title=CasesListPage.Filters.MAX_SLA_DAYS_REMAINING, options=sla_days), Select(name="min_sla_days_remaining", title=CasesListPage.Filters.MIN_SLA_DAYS_REMAINING, options=sla_days), Select(name="sla_days_elapsed", title=CasesListPage.Filters.SLA_DAYS_ELAPSED, options=sla_days), Select(name="sla_days_elapsed_sort_order", title=CasesListPage.Filters.SORT_BY_SLA_ELAPSED, options=sla_sort), DateInput( name="submitted_from", title=CasesListPage.Filters.SUBMITTED_FROM, prefix="submitted_from_", inline_title=True, ), DateInput(name="submitted_to", title=CasesListPage.Filters.SUBMITTED_TO, prefix="submitted_to_", inline_title=True), DateInput( name="finalised_from", title=CasesListPage.Filters.FINALISED_FROM, prefix="finalised_from_", inline_title=True, ), DateInput(name="finalised_to", title=CasesListPage.Filters.FINALISED_TO, prefix="finalised_to_", inline_title=True), TextInput(name="party_name", title=CasesListPage.Filters.PARY_NAME), TextInput(name="party_address", title=CasesListPage.Filters.PARTY_ADDRESS), TextInput(name="goods_related_description", title=CasesListPage.Filters.GOODS_RELATED_DESCRIPTION), AutocompleteInput( name="country", title=CasesListPage.Filters.COUNTRY, options=get_countries(request, convert_to_options=True), ), AutocompleteInput( name="control_list_entry", title=CasesListPage.Filters.CONTROL_LIST_ENTRY, options=get_control_list_entries(request, convert_to_options=True), ), TokenBar( name="flags", title=CasesListPage.Filters.FLAGS, options=[ Option(flag["id"], flag["name"]) for flag in get_flags(request, disable_pagination=True) ], ), ], )
def test_date_input(self): date = DateInput(prefix="Date", description=self.markdown_description) self.assertEqual(date.description, self.html_description)