def create_admin_user_form(): return Form( title="Create an admin user for this organisation", questions=[TextInput(title=RegisterAnOrganisation.EMAIL, name="user.email"),], default_button_name="Submit", helpers=[HelpSection("Help", RegisterAnOrganisation.DEFAULT_USER)], )
def set_flags_form(flags, level, show_case_header=False, show_sidebar=False): form = Form( title=getattr(SetFlagsForm, level).TITLE, description=getattr(SetFlagsForm, level).DESCRIPTION, questions=[ Filter(placeholder=getattr(SetFlagsForm, level).FILTER), Checkboxes( name="flags[]", options=flags, filterable=True, disabled_hint="You do not have permission to remove this flag.", ), DetailComponent( title=getattr(SetFlagsForm, level).Note.TITLE, components=[ TextArea(name="note", classes=["govuk-!-margin-0"]), ], ), ], default_button_name=getattr(SetFlagsForm, level).SUBMIT_BUTTON, container="case" if show_case_header else "two-pane", javascript_imports={"/javascripts/flags-permission-hints.js"}, ) if show_sidebar: form.helpers = [ HelpSection("Setting flags on:", "", includes="case/includes/selection-sidebar.html") ] return form
def edit_document_text_form(kwargs, post_url): return Form( title=GenerateDocumentsPage.EditTextForm.HEADING, questions=[TextArea(name="text", extras={"max_length": 5000}),], default_button_name=GenerateDocumentsPage.EditTextForm.BUTTON, post_url=reverse_lazy(post_url, kwargs=kwargs), helpers=[HelpSection(picklists.NewPicklistForm.HELP, None, "teams/markdown-help.html")], container="case", )
def review_goods_form(request, is_goods_type, **kwargs): return Form( title=cases.ReviewGoodsForm.HEADING, questions=[ RadioButtons( title=goods.ReviewGoods.IS_GOOD_CONTROLLED, name="is_good_controlled", options=[ Option( key=conditional(is_goods_type, True, "yes"), value="Yes", components=[ control_list_entries_question( control_list_entries=get_control_list_entries( request, convert_to_options=True), title=goods.ReviewGoods.ControlListEntries. TITLE, ), PicklistPicker( target="report_summary", title=goods.ReviewGoods.ReportSummary.TITLE, description=goods.ReviewGoods.ReportSummary. DESCRIPTION, type=PicklistCategories.report_summary.key, set_text=False, ), ], ), Option(key=conditional(is_goods_type, False, "no"), value="No"), ], ), DetailComponent( title=goods.ReviewGoods.Comment.TITLE, components=[ TextArea(name="comment", extras={ "max_length": 500, }), ], ), ], default_button_name=cases.ReviewGoodsForm.CONFIRM_BUTTON, container="case", back_link=BackLink(url=reverse("cases:case", kwargs={ "queue_pk": kwargs["queue_pk"], "pk": kwargs["pk"] })), helpers=[ HelpSection(goods.ReviewGoods.GIVING_ADVICE_ON, "", includes="case/includes/selection-sidebar.html") ], )
def add_letter_paragraph_form(picklist_type): return Form( title=picklists.NewPicklistForm.LETTER_PARAGRAPH, questions=[ HiddenField("type", picklist_type), TextInput(title=picklists.NewPicklistForm.Name.TITLE, name="name", classes=["govuk-!-width-full"]), MarkdownArea( title=picklists.NewPicklistForm.Text.TITLE, name="text", extras={ "max_length": 5000, }, ), ], helpers=[ HelpSection(picklists.NewPicklistForm.HELP, None, "teams/markdown-help.html") ], )
def review_goods_form(control_list_entries, back_url): return Form( title=cases.ReviewGoodsForm.HEADING, questions=[ RadioButtons( title=goods.ReviewGoods.IS_GOOD_CONTROLLED, name="is_good_controlled", options=[ Option(key=True, value="Yes"), Option(key=False, value="No"), ], ), control_list_entries_question( control_list_entries=control_list_entries, title=goods.ReviewGoods.ControlListEntries.TITLE, ), PicklistPicker( target="report_summary", title=goods.ReviewGoods.ReportSummary.TITLE, description=goods.ReviewGoods.ReportSummary.DESCRIPTION, type=PicklistCategories.report_summary.key, set_text=False, allow_clear=True, ), DetailComponent( title=goods.ReviewGoods.Comment.TITLE, components=[ TextArea(name="comment", extras={"max_length": 500}) ], ), ], default_button_name=cases.ReviewGoodsForm.CONFIRM_BUTTON, container="case", back_link=BackLink(url=back_url), helpers=[ HelpSection(goods.ReviewGoods.GIVING_ADVICE_ON, "", includes="case/includes/selection-sidebar.html") ], )
def edit_letter_paragraph_form(picklist_item): return Form( title=picklists.NewPicklistForm.EDIT_PREFIX + " " + picklist_item["name"], questions=[ HiddenField("type", picklist_item["type"]["key"]), TextInput(title=picklists.NewPicklistForm.Name.TITLE, name="name", classes=["govuk-!-width-full"]), MarkdownArea( title=picklists.NewPicklistForm.Text.TITLE, name="text", extras={ "max_length": 5000, }, ), ], helpers=[ HelpSection(picklists.NewPicklistForm.HELP, None, "teams/markdown-help.html") ], )
], default_button_name=advice.GiveOrChangeAdvicePage.Actions. CONTINUE_BUTTON, back_link=BackLink( advice.GiveOrChangeAdvicePage.Actions.BACK_BUTTON, reverse(f"cases:case", kwargs={ "queue_pk": queue_pk, "pk": case["id"], "tab": tab }), ), container="case", helpers=[ HelpSection(advice.GiveOrChangeAdvicePage.GIVING_ADVICE_ON, "", includes="case/includes/selection-sidebar.html") ], javascript_imports={"/javascripts/advice.js"}, ) def generate_documents_form(queue_pk, case_pk): return Form( title=GenerateGoodsDecisionForm.TITLE, questions=[ Custom("components/finalise-generate-documents.html"), DetailComponent( title=GenerateGoodsDecisionForm.NOTE, components=[ TextArea(title=GenerateGoodsDecisionForm.NOTE_DESCRIPTION,
def add_goods_questions(control_list_entries, application_pk=None): is_good_controlled_description = ( f"Products that aren't on the {PERMISSION_FINDER_LINK} may be affected by [military end use controls]" "(https://www.gov.uk/guidance/export-controls-military-goods-software-and-technology), " "[current trade sanctions and embargoes]" "(https://www.gov.uk/guidance/current-arms-embargoes-and-other-restrictions) or " "[weapons of mass destruction controls](https://www.gov.uk/guidance/supplementary-wmd-end-use-controls). " "If the product isn't subject to any controls, you'll get a no licence required (NLR) document from ECJU." ) is_pv_graded_description = ( "For example, UK OFFICIAL or NATO UNCLASSIFIED. The security grading of the product doesn't affect " "if an export licence is needed.") is_good_controlled_options = [ Option( key=True, value="Yes", components=[ control_list_entries_question( control_list_entries=control_list_entries, title="Control list entries", description="Type to get suggestions. For example, ML1a.", ), ], ), Option(key=False, value="No"), ] is_pv_graded_options = [ Option(key="yes", value="Yes"), Option(key="no", value="No, it doesn't need one"), ] if settings.FEATURE_FLAG_ONLY_ALLOW_SIEL: if not application_pk: controlled_spire = HelpSection( description=mark_safe( # nosec f"Use <a href='{settings.SPIRE_URL}'>SPIRE</a> to raise a control list classification (CLC) query" ), title="", ) pv_graded_spire = HelpSection( description=mark_safe( # nosec f"Use <a href='{settings.SPIRE_URL}'>SPIRE</a> to apply for a private venture (PV) grading", ), title="", ) is_good_controlled_options.append( Option(key=None, value="I don't know", components=[controlled_spire])) is_pv_graded_options.append( Option(key="grading_required", value="No, it needs one", components=[pv_graded_spire])) else: if not application_pk: is_good_controlled_options.append( Option( key=None, value= "I don't know, raise a control list classification (CLC) query" )) is_pv_graded_options.append( Option( key="grading_required", value= "No, it needs one, apply for a private venture (PV) grading" )) return Form( title=conditional(application_pk, "Add a product to your application", "Add a product to your product list"), questions=[ TextInput( title="Name", description= ("Give your product a name so it is easier to find in your product list" ), name="name", ), TextArea( title="Description", name="description", extras={"max_length": 280}, rows=5, optional=True, ), TextInput(title="Part number", name="part_number", optional=True), RadioButtons( title="Is the product on the control list?", description=is_good_controlled_description, name="is_good_controlled", options=is_good_controlled_options, ), RadioButtons( title="Does the product have a security grading?", description=is_pv_graded_description, name="is_pv_graded", options=is_pv_graded_options, ), ], back_link=conditional( application_pk, BackLink( "Back", reverse_lazy("applications:goods", kwargs={"pk": application_pk})), Breadcrumbs([ BackLink(generic.SERVICE_NAME, reverse_lazy("core:home")), BackLink(GoodsList.TITLE, reverse_lazy("goods:goods")), BackLink(GoodsList.CREATE_GOOD), ]), ), default_button_name="Continue", )
def test_help_section(self): detail = HelpSection(title="abc", description=self.markdown_description) self.assertEqual(detail.description, self.html_description)