def site_form(request, is_individual, location):
    from 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, "site.address."),
                foreign_address_questions(get_countries(request, True, ["GB"]), "site.address."),
            ),
        ],
        default_button_name=generic.CONTINUE,
    )
Beispiel #2
0
def create_default_site_form(request, in_uk):
    return Form(
        title=RegisterAnOrganisation.CREATE_DEFAULT_SITE,
        questions=[
            TextInput(title=RegisterAnOrganisation.NAME_OF_SITE, name="site.name"),
            Heading(RegisterAnOrganisation.WhereIsTheExporterBased.TITLE, HeadingStyle.M),
            *conditional(
                in_uk,
                address_questions(None, "site.address."),
                foreign_address_questions(get_countries(request, True, ["GB"]), "site.address."),
            ),
        ],
        default_button_name=strings.CONTINUE,
    )
Beispiel #3
0
def register_hmrc_organisation_forms():
    return FormGroup(
        [
            Form(
                title="Register an HMRC organisation",
                questions=[
                    HiddenField(name="type", value="hmrc"),
                    TextInput(title="Name of HMRC organisation", name="name"),
                    TextInput(title=RegisterAnOrganisation.NAME_OF_SITE, name="site.name"),
                    Heading("Where are they based?", HeadingStyle.M),
                    *address_questions(None, "site.address."),
                ],
                default_button_name="Continue",
            ),
            create_admin_user_form(),
        ],
        show_progress_indicators=True,
    )
Beispiel #4
0
def new_site_forms(request):
    in_uk = request.POST.get("location", "").lower() == "united_kingdom"
    sites = []
    if request.POST.get("address.postcode"):
        sites = get_sites(request,
                          request.user.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),
                    foreign_address_questions(
                        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.user.organisation,
                        {
                            "disable_pagination": True,
                            "exclude_permission": Permissions.ADMINISTER_SITES
                        },
                        True,
                    ),
                    filterable=True,
                ),
                HiddenField("validate_only", False),
            ],
            default_button_name=generic.SAVE_AND_CONTINUE,
        ),
    ])