コード例 #1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.fields[
            "certificate_type"].label_from_instance = lambda obj: f"{obj.sid} - {obj.description}"
        self.fields["certificate_type"].required = False

        if self.instance:
            self.fields["code"].disabled = True
            self.fields["code"].help_text = "You can't edit this"
            self.fields["code"].initial = self.instance.code

            self.fields["certificate_type"].disabled = True
            self.fields["certificate_type"].help_text = "You can't edit this"

        self.helper = FormHelper(self)
        self.helper.label_size = Size.SMALL
        self.helper.legend_size = Size.SMALL

        self.helper.layout = Layout(
            Field.text(
                "code",
                field_width=Fixed.TEN,
            ),
            "certificate_type",
            "start_date",
            "end_date",
            Submit("submit", "Save"),
        )
コード例 #2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.fields["footnote_type"].label_from_instance = (
            lambda obj: f"{obj.footnote_type_id} - {obj.description}")
        self.fields["footnote_type"].label = "Footnote type"
        self.fields["footnote_type"].required = False

        if self.instance:
            self.fields["code"].disabled = True
            self.fields["code"].help_text = "You can't edit this"
            self.fields["code"].initial = str(self.instance)

            self.fields["footnote_type"].disabled = True
            self.fields["footnote_type"].help_text = "You can't edit this"

            if self.instance.valid_between.lower:
                self.fields[
                    "start_date"].initial = self.instance.valid_between.lower
            if self.instance.valid_between.upper:
                self.fields[
                    "end_date"].initial = self.instance.valid_between.upper

        self.helper = FormHelper(self)
        self.helper.layout = Layout(
            Field.text(
                "code",
                field_width=Fixed.TEN,
                label_size=Size.SMALL,
            ),
            Field("footnote_type", context={"label_size": "govuk-label--s"}),
            Field("start_date", context={"legend_size": "govuk-label--s"}),
            Field("end_date", context={"legend_size": "govuk-label--s"}),
            Submit("submit", "Save"),
        )
コード例 #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.fields["footnote_type"].label_from_instance = (
            lambda obj: f"{obj.footnote_type_id} - {obj.description}")
        self.fields["footnote_type"].label = "Footnote type"
        self.fields["footnote_type"].required = False

        if self.instance:
            self.fields["code"].disabled = True
            self.fields["code"].help_text = "You can't edit this"
            self.fields["code"].initial = str(self.instance)

            self.fields["footnote_type"].disabled = True
            self.fields["footnote_type"].help_text = "You can't edit this"

        self.helper = FormHelper(self)
        self.helper.label_size = Size.SMALL
        self.helper.legend_size = Size.SMALL

        self.helper.layout = Layout(
            Field.text(
                "code",
                field_width=Fixed.TEN,
            ),
            Field("footnote_type"),
            Field("start_date"),
            Field("end_date"),
            Submit(
                "submit",
                "Save",
                data_module="govuk-button",
                data_prevent_double_click="true",
            ),
        )
コード例 #4
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",
         ),
     )
コード例 #5
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"),
     )
コード例 #6
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.layout = Layout(
            "additional_code",
            Submit("submit", "Continue"),
        )
コード例 #7
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.layout = Layout(
            "taric_file",
            Submit("submit", "Continue"),
        )
コード例 #8
0
ファイル: forms.py プロジェクト: uktrade/tamato
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.helper = FormHelper(self)
     self.helper.legend_size = Size.EXTRA_LARGE
     self.helper.layout = Layout(
         "workbasket_action",
         Submit(
             "submit",
             "Continue",
             data_module="govuk-button",
             data_prevent_double_click="true",
         ),
     )
コード例 #9
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.layout = Layout(
            "additional_code",
            Submit(
                "submit",
                "Continue",
                data_module="govuk-button",
                data_prevent_double_click="true",
            ),
        )
コード例 #10
0
ファイル: forms.py プロジェクト: uktrade/tamato
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.layout = Layout(
            Field("validity_start", context={"legend_size": "govuk-label--s"}),
            Field.textarea("description", label_size=Size.SMALL, rows=5),
            Submit(
                "submit",
                "Save",
                data_module="govuk-button",
                data_prevent_double_click="true",
            ),
        )
コード例 #11
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.label_size = Size.SMALL
        self.helper.legend_size = Size.SMALL
        self.helper.layout = Layout(
            "measure_type",
            "generating_regulation",
            "order_number",
            "start_date",
            "end_date",
            Submit("submit", "Continue"),
        )
コード例 #12
0
ファイル: forms.py プロジェクト: kintisheff/tamato
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        if self.instance.valid_between.lower:
            self.fields["start_date"].initial = self.instance.valid_between.lower
        if self.instance.valid_between.upper:
            self.fields["end_date"].initial = self.instance.valid_between.upper

        self.helper = FormHelper(self)
        self.helper.layout = Layout(
            Field("start_date", context={"legend_size": "govuk-label--s"}),
            Field.textarea("description", label_size=Size.SMALL, rows=5),
            Submit("submit", "Save"),
        )
コード例 #13
0
ファイル: forms.py プロジェクト: uktrade/tamato
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.label_size = Size.SMALL
        self.helper.legend_size = Size.SMALL
        self.helper.layout = Layout(
            Submit(
                "submit",
                "Delete",
                css_class="govuk-button--warning",
                data_module="govuk-button",
                data_prevent_double_click="true",
            ), )
コード例 #14
0
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop("request", None)
        super().__init__(*args, **kwargs)

        self.fields["footnote_type"].label_from_instance = (
            lambda obj: f"{obj.footnote_type_id} - {obj.description}")

        self.helper = FormHelper(self)
        self.helper.label_size = Size.SMALL
        self.helper.legend_size = Size.SMALL
        self.helper.layout = Layout(
            "footnote_type",
            "start_date",
            Field.textarea("description", rows=5),
            DescriptionHelpBox(),
            Submit("submit", "Save"),
        )
コード例 #15
0
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop("request", None)
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.label_size = Size.SMALL
        self.helper.legend_size = Size.SMALL
        self.helper.layout = Layout(
            "title",
            Field.textarea("reason", rows=5),
            DescriptionHelpBox(),
            Submit(
                "submit",
                "Create",
                data_module="govuk-button",
                data_prevent_double_click="true",
            ),
        )
コード例 #16
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        kwargs.pop("initial")

        self.fields["geo_area"].initial = self.data.get(f"{self.prefix}-geo_area")

        geographical_area_fields = {
            GeoAreaType.ERGA_OMNES: self.erga_omnes_instance,
            GeoAreaType.GROUP: self.data.get(f"{self.prefix}-geographical_area_group"),
            GeoAreaType.COUNTRY: self.data.get(
                f"{self.prefix}-geographical_area_country_or_region",
            ),
        }

        nested_forms_initial = {}

        if self.fields["geo_area"].initial:
            nested_forms_initial["geographical_area"] = geographical_area_fields[
                self.fields["geo_area"].initial
            ]

        self.bind_nested_forms(*args, initial=nested_forms_initial, **kwargs)

        self.helper = FormHelper(self)
        self.helper.label_size = Size.SMALL
        self.helper.legend_size = Size.SMALL
        self.helper.layout = Layout(
            "geo_area",
            HTML.details(
                "Help with geography",
                (
                    "Choose the geographical area to which the measure applies. This can be a specific country "
                    "or a group of countries, and exclusions can be specified. The measure will only apply to imports "
                    "from or exports to the selected area."
                ),
            ),
            Submit(
                "submit",
                "Continue",
                data_module="govuk-button",
                data_prevent_double_click="true",
            ),
        )
コード例 #17
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.label_size = Size.SMALL
        self.helper.legend_size = Size.SMALL
        self.helper.layout = Layout(
            "measure_type",
            "generating_regulation",
            "order_number",
            "start_date",
            "end_date",
            Submit(
                "submit",
                "Continue",
                data_module="govuk-button",
                data_prevent_double_click="true",
            ),
        )
コード例 #18
0
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop("request", None)
        super().__init__(*args, **kwargs)

        self.fields[
            "type"
        ].label_from_instance = lambda obj: f"{obj.sid} - {obj.description}"

        self.helper = FormHelper(self)
        self.helper.label_size = Size.SMALL
        self.helper.legend_size = Size.SMALL
        self.helper.layout = Layout(
            "type",
            Field.text("code", field_width=Fluid.ONE_QUARTER, maxlength="3"),
            "start_date",
            Field.textarea("description", rows=5),
            DescriptionHelpBox(),
            Submit("submit", "Save"),
        )
コード例 #19
0
ファイル: forms.py プロジェクト: uktrade/tamato
    def __init__(self, *args, **kwargs):
        self.request = kwargs.pop("request", None)
        super().__init__(*args, **kwargs)

        self.fields[
            "certificate_type"].label_from_instance = lambda obj: f"{obj.sid} - {obj.description}"

        self.helper = FormHelper(self)
        self.helper.label_size = Size.SMALL
        self.helper.legend_size = Size.SMALL
        self.helper.layout = Layout(
            "certificate_type",
            "sid",
            "start_date",
            Field.textarea("description", rows=5),
            DescriptionHelpBox(),
            Submit(
                "submit",
                "Save",
                data_module="govuk-button",
                data_prevent_double_click="true",
            ),
        )
コード例 #20
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.helper = FormHelper(self)
        self.helper.add_input(Submit("", self.submit_text))