Beispiel #1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.form_tag = False

        self.helper.layout = Layout(
            Fieldset(
                Div(
                    Field(
                        "condition_code",
                        template="components/measure_condition_code/template.jinja",
                    ),
                    "condition_sid",
                ),
                Div(
                    Field("reference_price", css_class="govuk-input"),
                    "required_certificate",
                    css_class="govuk-radios__conditional",
                ),
                Field(
                    "action",
                    template="components/measure_condition_action_code/template.jinja",
                ),
                Div(
                    MeasureConditionComponentDuty("applicable_duty"),
                ),
                Field("DELETE", template="includes/common/formset-delete-button.jinja")
                if not self.prefix.endswith("__prefix__")
                else None,
                legend="Condition code",
                legend_size=Size.SMALL,
                data_field="condition_code",
            ),
        )
Beispiel #2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper.layout = Layout(
         Fieldset(
             "public_identifier",
             self._load_details_from_template(
                 "Help with public identifiers",
                 "regulations/help_public_identifiers.jinja",
             ),
             Field(
                 "url",
                 css_class="govuk-input",
             ),
             "regulation_group",
             self._load_details_from_template(
                 "Help with regulation group",
                 "regulations/help_regulation_group.jinja",
             ),
             "information_text",
             "start_date",
             "end_date",
             "published_at",
             HTML.details(
                 "Help with Published date",
                 RegulationFormBase.PUBLISHED_AT_HELP_TEXT,
             ),
             "approved",
         ),
         Submit(
             "submit",
             "Save",
             data_module="govuk-button",
             data_prevent_double_click="true",
         ),
     )
def test_change_legend_size():
    """Verify size of the field legend can be changed from the default."""
    form = FieldsetForm()
    form.helper = FormHelper()
    form.helper.layout = Layout(
        Fieldset("name", "email", legend="Contact", legend_size=Size.LARGE))
    assert parse_form(form) == parse_contents(RESULT_DIR, "legend_size.html")
Beispiel #4
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper.layout = Layout(
         Fieldset(
             "regulation_usage",
             "public_identifier",
             self._load_details_from_template(
                 "Help with public identifiers",
                 "regulations/help_public_identifiers.jinja",
             ),
             Field(
                 "url",
                 css_class="govuk-input",
             ),
             "regulation_group",
             self._load_details_from_template(
                 "Help with regulation group",
                 "regulations/help_regulation_group.jinja",
             ),
             "information_text",
             "start_date",
             "end_date",
             "published_at",
             Field(
                 "sequence_number",
                 css_class="govuk-input govuk-input--width-5",
             ),
             self._load_details_from_template(
                 "Help with sequence number",
                 "regulations/help_sequence_number.jinja",
             ),
             "approved",
         ),
         Submit("submit", "Save"),
     )
def test_show_legend_as_heading():
    """Verify the field legend can be displayed as the page heading."""
    form = FieldsetForm()
    form.helper = FormHelper()
    form.helper.layout = Layout(
        Fieldset("name", "email", legend="Contact", legend_tag="h1"))
    assert parse_form(form) == parse_contents(RESULT_DIR,
                                              "legend_heading.html")
Beispiel #6
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.label_size = Size.for_label(Size.SMALL)
     self.helper.layout = Layout(
         Fieldset(
             Field.text("name"),
             Field.text("email", field_width=Fluid.TWO_THIRDS),
             Field.text("phone", field_width=Fixed.TEN),
         ),
         Button("submit", "Submit"),
     )
Beispiel #7
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Fieldset(
             Field.text("street1", field_width=Fluid.THREE_QUARTERS),
             Field.text("street2", field_width=Fluid.THREE_QUARTERS),
             Field.text("city", field_width=Fluid.ONE_HALF),
             Field.text("county", field_width=Fluid.ONE_HALF),
             Field.text("postcode", field_width=Fluid.ONE_QUARTER),
             legend="What is your address?",
             legend_size=Size.LARGE,
             legend_tag="h1",
         )
     )
Beispiel #8
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.form_tag = False
        self.helper.legend_size = Size.SMALL
        self.helper.layout = Layout(
            Fieldset(
                "footnote",
                Field("DELETE",
                      template="includes/common/formset-delete-button.jinja")
                if not self.prefix.endswith("__prefix__") else None,
                legend="Footnote",
                legend_size=Size.SMALL,
            ), )
Beispiel #9
0
    def __init__(self, *args, **kwargs):
        # remove measure_start_date from kwargs here because superclass will not be expecting it
        self.measure_start_date = kwargs.pop("measure_start_date")
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.form_tag = False
        self.helper.label_size = Size.SMALL
        self.helper.layout = Layout(
            Fieldset(
                "commodity",
                "duties",
                HTML(
                    loader.render_to_string(
                        "components/duty_help.jinja",
                        context={"component": "measure"},
                    ), ),
                Field("DELETE",
                      template="includes/common/formset-delete-button.jinja")
                if not self.prefix.endswith("__prefix__") else None,
            ), )
Beispiel #10
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(Fieldset("name", "email",
                                          legend="Contact"))
def test_attribute():
    """Verify the extra attributes can be added."""
    form = FieldsetForm()
    form.helper = FormHelper()
    form.helper.layout = Layout(Fieldset(key="value"))
    assert parse_form(form) == parse_contents(RESULT_DIR, "attributes.html")
def test_css_id():
    """Verify the id attribute can be set on the fieldset."""
    form = FieldsetForm()
    form.helper = FormHelper()
    form.helper.layout = Layout(Fieldset(css_id="new_id"))
    assert parse_form(form) == parse_contents(RESULT_DIR, "css_id.html")
def test_css_class():
    """Verify an extra CSS class can be added to the fieldset."""
    form = FieldsetForm()
    form.helper = FormHelper()
    form.helper.layout = Layout(Fieldset(css_class="extra-css-class"))
    assert parse_form(form) == parse_contents(RESULT_DIR, "css_class.html")