Ejemplo n.º 1
0
def delete_good_form(good):
    return Form(
        title=EditGoodForm.DeleteConfirmationForm.TITLE,
        questions=[good_summary(good)],
        buttons=[
            Button(value=EditGoodForm.DeleteConfirmationForm.YES, action="submit", style=ButtonStyle.WARNING),
            Button(
                value=EditGoodForm.DeleteConfirmationForm.NO,
                action="",
                style=ButtonStyle.SECONDARY,
                link=reverse_lazy("goods:good", kwargs={"pk": good["id"]}),
            ),
        ],
    )
Ejemplo n.º 2
0
def select_flags(request, team_id, flags_to_include, flags_to_exclude,
                 is_editing):

    flags_checkboxes = [
        Option(flag["id"],
               flag["name"],
               data_attribute=get_flag_details_html(flag))
        for flag in get_flags_for_team_of_level(
            request, level="", team_id=team_id, include_system_flags=True)
    ]

    return Form(
        title=Forms.FLAGS if not is_editing else "Edit flags",
        questions=[
            HiddenField(name="flags_to_include",
                        value=",".join(flags_to_include)),
            HiddenField(name="flags_to_exclude",
                        value=",".join(flags_to_exclude)),
            HTMLBlock("<div id='routing-rules-flags-details'></div>"),
            Label(id="condition-label", text="Apply the routing rule to:"),
            RadioButtons(
                title="",
                name="routing_rules_flags_condition",
                options=[
                    Option(key="contain_selected_flags",
                           value="Cases that contain selected flags"),
                    Option(key="doesnot_contain_selected_flags",
                           value="Cases that do not contain selected flags"),
                ],
            ),
            Filter(),
            Checkboxes(
                name="flags[]",
                options=flags_checkboxes,
                import_custom_js=[
                    "/javascripts/filter-checkbox-list-flags.js"
                ],
            ),
        ],
        buttons=[
            Button("Save and continue", "submit", id="save_and_continue"),
            Button("Add another condition",
                   "",
                   ButtonStyle.SECONDARY,
                   id="add-another-condition",
                   link="#"),
        ],
        javascript_imports={"/javascripts/routing-rules-flags.js"},
    )
Ejemplo n.º 3
0
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"},
    )
Ejemplo n.º 4
0
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"})),
    )
Ejemplo n.º 5
0
def assign_case_officer_form(request: HttpRequest,
                             existing_officer,
                             queue_id,
                             case_id,
                             is_compliance=None):
    params = {"disable_pagination": True, "status": UserStatuses.ACTIVE}
    users = get_gov_users(request, params, convert_to_options=True)
    buttons = [
        Button(cases.Manage.AssignCaseOfficer.SUBMIT_BUTTON, action="submit")
    ]
    if existing_officer:
        buttons.append(
            Button(
                conditional(
                    is_compliance,
                    cases.Manage.AssignCaseOfficer.DELETE_INSPECTOR_BUTTON,
                    cases.Manage.AssignCaseOfficer.DELETE_BUTTON,
                ),
                action="delete",
                id="unassign",
                style=ButtonStyle.WARNING,
            ))

    return Form(
        title=conditional(is_compliance,
                          cases.Manage.AssignCaseOfficer.INSPECTOR_TITLE,
                          cases.Manage.AssignCaseOfficer.TITLE),
        description=cases.Manage.AssignCaseOfficer.DESCRIPTION,
        questions=[
            Filter(),
            RadioButtons("gov_user_pk", users, filterable=True)
        ],
        buttons=buttons,
        container="case",
        back_link=BackLink(url=reverse("cases:case",
                                       kwargs={
                                           "queue_pk": queue_id,
                                           "pk": case_id,
                                           "tab": "details"
                                       })),
    )
Ejemplo n.º 6
0
def deactivate_picklist_item(picklist_item):
    return Form(
        title="Are you sure you want to deactivate " + picklist_item["name"] +
        "?",
        description="You can always reactivate it later if need be.",
        questions=[],
        back_link=BackLink(
            "Back",
            reverse_lazy("picklists:edit", kwargs={"pk":
                                                   picklist_item["id"]})),
        buttons=[
            Button("Deactivate", "submit", ButtonStyle.WARNING),
            Button(
                "Cancel",
                "cancel",
                ButtonStyle.SECONDARY,
                reverse_lazy("picklists:edit",
                             kwargs={"pk": picklist_item["id"]}),
            ),
        ],
    )
Ejemplo n.º 7
0
def attach_documents_form(back_link):
    return Form(
        title=AttachDocumentForm.TITLE,
        description=AttachDocumentForm.DESCRIPTION,
        questions=[
            FileUpload(),
            TextArea(
                title=AttachDocumentForm.Description.TITLE,
                optional=True,
                name="description",
                extras={"max_length": 280},
            ),
        ],
        buttons=[Button(AttachDocumentForm.BUTTON, "submit")],
        back_link=back_link,
    )
Ejemplo n.º 8
0
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.user.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),
        ),
    ])