示例#1
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Div(Button.primary("add", "Add contact")),
         Div(Button.secondary("find", "Find address")),
         Div(Button.secondary("win", "Win lottery", disabled=True)),
         Div(Button.warning("delete", "Delete account")),
         Div(HTML(button_link(reverse("home"), "Go Home"))),
     )
示例#2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Field.checkboxes("method", legend_size=Size.MEDIUM, small=True),
         Button("submit", "Submit"),
     )
示例#3
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         "sort_by",
         Button("submit", "Submit"),
     )
示例#4
0
    def __init__(self, *args, **kwargs):
        super(DateInputForm, self).__init__(*args, **kwargs)
        self.helper = FormHelper()
        self.helper.layout = Layout("date", Button("submit", _("Submit")))

        self.fields["date"].fields[2].error_messages[
            "incomplete"] = "The date your passport was issued must include a year"
示例#5
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Field.textarea("description", rows=3, max_words=100,),
         Button("submit", "Submit"),
     )
示例#6
0
 def valid_layout(self):
     value = self.cleaned_data["sort_by"]
     self.helper.layout = Layout(
         Hidden("sort_by", value),
         HTML.h2("You answered..."),
         HTML.table(None, [("Sort by:", self.get_choice("sort_by"))]),
         Button("continue", "Continue"),
     )
示例#7
0
 def valid_layout(self):
     value = self.cleaned_data["description"]
     self.helper.layout = Layout(
         Hidden("description", value),
         HTML.h2("You answered..."),
         HTML.p(value),
         Button("continue", "Continue"),
     )
示例#8
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()

        self.helper.layout = Layout(
            *self.fields,
            Button("submit", "Upload"),
        )
示例#9
0
 def valid_layout(self):
     self.fields["method"].widget = MultipleHiddenInput()
     self.helper.layout = Layout(
         "method",
         HTML.h2("You answered..."),
         HTML.table(None, [("Methods selected:", self.get_method())]),
         Button("continue", "Continue"),
     )
示例#10
0
 def valid_layout(self):
     value = self.cleaned_data["date"]
     self.helper.layout = Layout(
         Hidden("date_0", value.day),
         Hidden("date_1", value.month),
         Hidden("date_2", value.year),
         HTML.h2("You answered..."),
         HTML.table(None, [("Date:", value.strftime("%e %B %Y"))]),
         Button("continue", "Continue"),
     )
示例#11
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.layout = Layout(
         Field.radios("name",
                      legend_size=Size.MEDIUM,
                      legend_tag="h1",
                      inline=True),
         Field.radios("method", legend_size=Size.MEDIUM, small=True),
         Button("submit", "Submit"),
     )
示例#12
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"),
     )
示例#13
0
 def valid_layout(self):
     name = self.cleaned_data["name"]
     email = self.cleaned_data["email"]
     phone = self.cleaned_data["phone"]
     self.helper.layout = Layout(
         Hidden("name", name),
         Hidden("email", email),
         Hidden("phone", phone),
         HTML.h2("You answered..."),
         HTML.table(None, [("Name:", name), ("Email:", email),
                           ("Phone:", phone)]),
         Button("continue", "Continue"),
     )
示例#14
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper()
     self.helper.label_size = Size.SMALL
     self.helper.legend_size = Size.SMALL
     self.helper.layout = Layout(
         Div(
             Field.text("sid", field_width=Fluid.TWO_THIRDS),
             "goods_nomenclature",
             "additional_code",
             "order_number",
             "measure_type",
             "regulation",
             "geographical_area",
             "footnote",
             css_class="govuk-grid-row quarters",
         ),
         HTML(
             '<hr class="govuk-section-break govuk-section-break--s govuk-section-break--visible">',
         ),
         Div(
             Div(
                 Field.radios(
                     "start_date_modifier",
                     inline=True,
                 ),
                 "start_date",
                 css_class=
                 "govuk-grid-column-one-half form-group-margin-bottom-2",
             ),
             Div(
                 Field.radios(
                     "end_date_modifier",
                     inline=True,
                 ),
                 "end_date",
                 css_class=
                 "govuk-grid-column-one-half form-group-margin-bottom-2",
             ),
             css_class="govuk-grid-row govuk-!-margin-top-6",
         ),
         HTML(
             '<hr class="govuk-section-break govuk-section-break--s govuk-section-break--visible">',
         ),
         Button("submit",
                "Search and Filter",
                css_class="govuk-!-margin-top-6"),
         HTML(
             f'<a class="govuk-button govuk-button--secondary govuk-!-margin-top-6" href="{self.clear_url}"> Clear </a>',
         ),
     )
示例#15
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()

        self.helper.layout = Layout(
            Field.text("order_number", label_size=Size.SMALL),
            Field.text("origin", label_size=Size.SMALL),
            Field.radios("mechanism", legend_size=Size.SMALL),
            Field.radios("category", legend_size=Size.SMALL),
            Button("submit", "Search and Filter", css_class="govuk-!-margin-top-6"),
            HTML(
                f'<a class="govuk-button govuk-button--secondary govuk-!-margin-top-6" href="{self.clear_url}"> Clear </a>',
            ),
        )
示例#16
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.helper = FormHelper()

        field_layout = (
            field_to_layout(field_name, field)
            for field_name, field in self.fields.items()
        )

        self.helper.layout = Layout(
            *field_layout,
            Button("submit", "Search and Filter"),
            HTML(
                f'<a class="govuk-button govuk-button--secondary" href="{self.clear_url}"> Clear </a>',
            ),
        )
示例#17
0
 def valid_layout(self):
     name = self.cleaned_data["name"]
     method = self.cleaned_data["method"]
     self.helper.layout = Layout(
         Hidden("name", name),
         Hidden("method", method),
         HTML.h2("You answered..."),
         HTML.table(
             None,
             [
                 ("Name changed:", self.get_choice("name")),
                 ("Contact method:", self.get_choice("method")),
             ],
         ),
         Button("continue", "Continue"),
     )
示例#18
0
def test_extra_attributes():
    button = Button.primary("name", "Title", key="value")
    assert parse_template(TEMPLATE, input=button) == parse_contents(
        RESULT_DIR, "attributes.html"
    )
示例#19
0
def test_css_id():
    button = Button.primary("name", "Title", css_id="new_id")
    assert parse_template(TEMPLATE, input=button) == parse_contents(
        RESULT_DIR, "css_id.html"
    )
示例#20
0
def test_css_class():
    button = Button.primary("name", "Title", css_class="extra-css-class")
    assert parse_template(TEMPLATE, input=button) == parse_contents(
        RESULT_DIR, "css_class.html"
    )
示例#21
0
def test_disabled_button():
    button = Button.primary("name", "Title", disabled=True)
    assert parse_template(TEMPLATE, input=button) == parse_contents(
        RESULT_DIR, "disabled.html"
    )
示例#22
0
def test_warning_button():
    button = Button.warning("name", "Title")
    assert parse_template(TEMPLATE, input=button) == parse_contents(
        RESULT_DIR, "warning.html"
    )
示例#23
0
def test_secondary_button():
    button = Button.secondary("name", "Title")
    assert parse_template(TEMPLATE, input=button) == parse_contents(
        RESULT_DIR, "secondary.html"
    )
示例#24
0
 def valid_layout(self):
     message = 'You clicked the "%s" button.' % self.get_button()
     self.helper.layout = Layout(HTML.p(message),
                                 Button("continue", "Continue"))