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"}, )
def upload_document_form(queue_pk): return Form( UploadEnforcementXML.TITLE, UploadEnforcementXML.DESCRIPTION, [ FileUpload(name="file"), ], back_link=BackLink( UploadEnforcementXML.BACK_LINK, reverse_lazy("queues:cases", kwargs={"queue_pk": queue_pk})), )
def attach_firearm_dealer_certificate_form(back_url): return Form( title="Attach your registered firearms dealer certificate", description="The file must be smaller than 50MB", questions=[ FileUpload(), TextInput(name="reference_code", title="Certificate number",), DateInput( prefix="expiry_date_", name="expiry_date", title="Expiry date", description="For example 12 3 2021" ), ], back_link=BackLink("Back", back_url), )
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, )
def attach_document_form(application_id, strings, back_link, is_optional): return Form( strings.TITLE, strings.DESCRIPTION, [ FileUpload(optional=is_optional), TextArea(title=strings.DESCRIPTION_FIELD_TITLE, optional=True, name="description"), ], back_link=BackLink( strings.BACK, reverse_lazy(back_link, kwargs={"pk": application_id})), footer_label=Label( 'Or <a id="return_to_application" href="' + str( reverse_lazy("applications:task_list", kwargs={"pk": application_id})) + '" class="govuk-link govuk-link--no-visited-state">' + strings.SAVE_AND_RETURN_LATER + "</a> " + strings.ATTACH_LATER), )
def test_file_upload_accept_props(self): """Test that vanilla FileUpload component is rendered with the right accept props. """ form = Form("test-file-upload", "A form to test file upload component", [FileUpload()]) html = render_to_string("form.html", {"page": form}) soup = BeautifulSoup(html, "html.parser") accept = soup.find(id="file")["accept"].split(",") assert accept == [ "application/pdf", "application/msword", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/rtf", "application/xml", "text/xml", "text/plain", "text/csv", "image/jpeg", "image/png", "image/tiff", ]
def attach_documents_form(case_url): return Form( cases.Manage.Documents.AttachDocuments.TITLE, cases.Manage.Documents.AttachDocuments.DESCRIPTION, [ FileUpload(), TextArea( title=cases.Manage.Documents.AttachDocuments. DESCRIPTION_FIELD_TITLE, optional=True, name="description", extras={ "max_length": 280, }, ), ], back_link=BackLink( cases.Manage.Documents.AttachDocuments.BACK_TO_CASE_DOCUMENTS, case_url), container="case", )
def open_licence_return_form_group(): return FormGroup([ Form( title=OpenReturnsHelpPage.TITLE, questions=[ Label(OpenReturnsHelpPage.DESCRIPTION), DetailComponent(OpenReturnsHelpPage.FORMATTING_HELP_LINK, OpenReturnsHelpPage.FORMATTING_HELP_DETAILS), ], default_button_name=OpenReturnsHelpPage.BUTTON, back_link=BackLink(OpenReturnsHelpPage.BACK, reverse_lazy("core:home")), ), Form( title=OpenReturnsForm.Year.TITLE, description=OpenReturnsForm.Year.DESCRIPTION, questions=[ Select( title=OpenReturnsForm.Year.FIELD_TITLE, description=OpenReturnsForm.Year.FIELD_DESCRIPTION, name="year", options=get_years(), ) ], default_button_name=OpenReturnsForm.Year.BUTTON, ), Form( title=OpenReturnsForm.Upload.TITLE, description=OpenReturnsForm.Upload.DESCRIPTION, questions=[ FileUpload(), Label(OpenReturnsForm.Upload.ExampleTable.HEADING), Custom("components/spreadsheet.html"), ], default_button_name=OpenReturnsForm.Upload.BUTTON, ), ])