From e5d58be3e786ce5c5630457f999a53a9b2003c73 Mon Sep 17 00:00:00 2001 From: Gurdeep Atwal Date: Wed, 30 Oct 2024 09:18:54 +0000 Subject: [PATCH] lint fixes and removed mark_down method --- exporter/applications/forms/questions.py | 6 ++- .../forms/trade_control_licence.py | 19 ++++++--- .../forms/triage_questions.py | 6 ++- exporter/compliance/forms.py | 41 ++++++++++--------- exporter/goods/forms/goods.py | 15 +++++-- .../lite_exporter_frontend/applications.py | 2 +- .../lite_exporter_frontend/compliance.py | 10 +++-- lite_content/lite_exporter_frontend/goods.py | 25 +++++++---- lite_forms/helpers.py | 15 ------- lite_forms/tests.py | 3 +- .../exporter/applications/test_components.py | 12 ++++++ 11 files changed, 91 insertions(+), 63 deletions(-) create mode 100644 unit_tests/exporter/applications/test_components.py diff --git a/exporter/applications/forms/questions.py b/exporter/applications/forms/questions.py index 02e7a0fd8c..a7be9cbcf7 100644 --- a/exporter/applications/forms/questions.py +++ b/exporter/applications/forms/questions.py @@ -130,8 +130,10 @@ def electronic_warfare_form(): value="Yes", components=[ Label( - text="""You need to complete part A of the MOD EW Data Release Capture Form - and attach it to the application in the supporting documents section.""" + text=( + "You need to complete part A of the MOD EW Data Release Capture" + " Form and attach it to the application in the supporting documents section." + ) ) ], ), diff --git a/exporter/apply_for_a_licence/forms/trade_control_licence.py b/exporter/apply_for_a_licence/forms/trade_control_licence.py index 9ba89d7d7c..b7bfed0758 100644 --- a/exporter/apply_for_a_licence/forms/trade_control_licence.py +++ b/exporter/apply_for_a_licence/forms/trade_control_licence.py @@ -18,8 +18,10 @@ def application_type_form(): Option( key=CaseTypes.OGTCL, value=TradeControlLicenceQuestions.TradeControlLicenceQuestion.OPEN_GENERAL_TRADE_CONTROL_LICENCE, - description="""Select to register a pre-published licence with set terms and conditions. Being an OGTCL holder can benefit your - business by saving time and money.""", + description=( + "Select to register a pre-published licence with set terms and conditions. " + "Being an OGTCL holder can benefit your business by saving time and money." + ), ), Option( key=CaseTypes.SICL, @@ -29,8 +31,10 @@ def application_type_form(): Option( key=CaseTypes.OICL, value=TradeControlLicenceQuestions.TradeControlLicenceQuestion.OPEN_LICENCE, - description="""Select an open licence for multiple shipments of specific products to specific destinations. - Open licences cover long term projects and repeat business.""", + description=( + "Select an open licence for multiple shipments of specific products to specific destinations. " + "Open licences cover long term projects and repeat business." + ), ), ], ) @@ -77,7 +81,12 @@ def product_category_form(request): "category_b": TradeControlLicenceQuestions.ProductCategory.CATEGORY_B_HINT, "category_c": TradeControlLicenceQuestions.ProductCategory.CATEGORY_C_HINT, } - PRODUCT_CATEGORY_DESCRIPTION = """Find out about trade control product categories.""" + guidence_url = "https://www.gov.uk/guidance/export-controls-military-goods-software-and-technology#trade-controls-and-arranging-sales-or-movements" + PRODUCT_CATEGORY_DESCRIPTION = ( + 'Find out about ' + "trade control product categories." + ) options = [ Option(product_category["key"], product_category["value"], hint_text_map.get(product_category["key"])) diff --git a/exporter/apply_for_a_licence/forms/triage_questions.py b/exporter/apply_for_a_licence/forms/triage_questions.py index 7b7548ee88..6db4c7e9c9 100644 --- a/exporter/apply_for_a_licence/forms/triage_questions.py +++ b/exporter/apply_for_a_licence/forms/triage_questions.py @@ -226,8 +226,10 @@ def transhipment_questions(request): Option( key=CaseTypes.OGTL, value=TranshipmentQuestions.TranshipmentLicenceQuestion.OPEN_GENERAL_TRANSHIPMENT_LICENCE, - description="""Select to register a pre-published licence with set terms and conditions. Being an OGTL holder can benefit your - business by saving time and money. """, + description=( + "Select to register a pre-published licence with set terms and conditions. Being an OGTL holder can benefit your " + "business by saving time and money." + ), ), Option( key=CaseTypes.SITL, diff --git a/exporter/compliance/forms.py b/exporter/compliance/forms.py index 579c721476..3f2fc89d6d 100644 --- a/exporter/compliance/forms.py +++ b/exporter/compliance/forms.py @@ -12,25 +12,28 @@ def get_years(): def open_licence_return_form_group(): - FORMATTING_HELP_DETAILS = """ - The first row must contain column headers, or be blank. It must not contain returns data.
Columns must start from column A and be in the following order:

Licence number must be in one of the following formats:

Destination names must be entered exactly as they appear on the licence.

End user type must be one of the following, entered exactly as shown here:

Usage count must be a positive integer.

Period must be in the following format, entered exactly as shown with YY replaced with the last 2 digits of the year:
- """ + FORMATTING_HELP_DETAILS = ( + "The first row must contain column headers, or be blank." + "It must not contain returns data.
Columns must start from column A and be in the following order:

Licence number must be in one of the following formats:

Destination names must be entered exactly as they appear on the licence." + "

End user type must be one of the following, entered exactly as shown here:

Usage count must be a positive integer." + "

Period must be in the following format, entered exactly as shown with YY replaced with the last 2 digits of the year:
" + ) return FormGroup( [ Form( diff --git a/exporter/goods/forms/goods.py b/exporter/goods/forms/goods.py index 2524908872..e94f69cbbf 100644 --- a/exporter/goods/forms/goods.py +++ b/exporter/goods/forms/goods.py @@ -52,7 +52,6 @@ TextArea, TextInput, ) -from lite_forms.helpers import convert_to_markdown from lite_forms.styles import ButtonStyle, HeadingStyle @@ -149,7 +148,11 @@ def edit_good_detail_form(request, good_id): def check_document_available_form(back_url): - DESCRIPTION = """For example, a technical specification, datasheet, sales brochure or something else that fully describes the product details.
This is required in order to process the application.""" + DESCRIPTION = ( + "For example, a technical specification, datasheet, " + "sales brochure or something else that fully describes the product details." + "
This is required in order to process the application." + ) return Form( title=DocumentAvailabilityForm.TITLE, @@ -204,7 +207,11 @@ def document_grading_form(back_url): def attach_documents_form(back_link): - DESCRIPTION = """Upload a DOCX, DOC, PDF, PNG, JPEG or ODT file.
Documentation could be specifications, datasheets, sales brochures, drawings or anything else that fully details what the product is and what it's designed to do.
Do not attach a document that’s above OFFICIAL-SENSITIVE.
The file must be smaller than 50MB.""" + DESCRIPTION = ( + "Upload a DOCX, DOC, PDF, PNG, JPEG or ODT file.
Documentation could be specifications, datasheets, " + "sales brochures, drawings or anything else that fully details what the product is and what it's designed to do." + "
Do not attach a document that’s above OFFICIAL-SENSITIVE.
The file must be smaller than 50MB." + ) return Form( title=AttachDocumentForm.TITLE, @@ -810,7 +817,7 @@ class AddGoodsQuestionsForm(forms.Form): (False, CreateGoodForm.IsControlled.NO), ), label=CreateGoodForm.IsControlled.TITLE, - help_text=convert_to_markdown(CreateGoodForm.IsControlled.DESCRIPTION), + help_text=CreateGoodForm.IsControlled.DESCRIPTION, ) control_list_entries = forms.MultipleChoiceField( diff --git a/lite_content/lite_exporter_frontend/applications.py b/lite_content/lite_exporter_frontend/applications.py index 01bebbdccb..88d3d6c9f2 100644 --- a/lite_content/lite_exporter_frontend/applications.py +++ b/lite_content/lite_exporter_frontend/applications.py @@ -223,7 +223,7 @@ class ReferenceNameQuestion: class ExportLicenceQuestions: class HaveYouBeenInformedQuestion: TITLE = "Have you received a letter or email from Border Force or HMRC informing you to apply for a licence?" - DESCRIPTION = "Give the application a reference name so you can refer back to it when needed." + DESCRIPTION = "You may know this as an 'end use control'." WHAT_WAS_THE_REFERENCE_CODE_TITLE = "Reference number" WHAT_WAS_THE_REFERENCE_CODE_DESCRIPTION = ( "For example, CRE/2020/1234567. The reference number is on the letter or email." diff --git a/lite_content/lite_exporter_frontend/compliance.py b/lite_content/lite_exporter_frontend/compliance.py index a09f5de4d9..e766416228 100644 --- a/lite_content/lite_exporter_frontend/compliance.py +++ b/lite_content/lite_exporter_frontend/compliance.py @@ -1,10 +1,12 @@ class OpenReturnsHelpPage: TITLE = "Before you start" BACK = "Back to hub" - DESCRIPTION = """Submit open licence returns using a CSV file that follows this [template and guidance](https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/385687/14-1290-open-licence-returns.pdf).
- You must submit open licence returns for:
- - Open Individual Export Licences (OIELs)
- Open Individual Trade Control Licences (OITCLs)
- Open General Export Licences (OGELs)\n - Open General Trade Control Licences (OGTCLs) - """ # noqa + DESCRIPTION = ( + "Submit open licence returns using a CSV file that follows this [template and guidance]" + "(https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/385687/14-1290-open-licence-returns.pdf).
" + " You must submit open licence returns for:
- Open Individual Export Licences (OIELs)
" + "- Open Individual Trade Control Licences (OITCLs)
- Open General Export Licences (OGELs)
- Open General Trade Control Licences (OGTCLs)" + ) BUTTON = "Next" diff --git a/lite_content/lite_exporter_frontend/goods.py b/lite_content/lite_exporter_frontend/goods.py index 74fd0c26ed..ca7ecf9381 100644 --- a/lite_content/lite_exporter_frontend/goods.py +++ b/lite_content/lite_exporter_frontend/goods.py @@ -115,9 +115,12 @@ class DocumentAvailabilityForm: class DocumentSensitivityForm: TITLE = "Is the document rated above OFFICIAL-SENSITIVE?" - ECJU_HELPLINE = """
Contact ECJU to arrange a more secure way to send this document.
You can continue with the application without attaching a document.
ECJU helpline
- 020 7215 4594
Find out about call charges (opens in new tab) -""" + ECJU_HELPLINE = """ +
Contact ECJU to arrange a more secure way to send this document. +
You can continue with the application without attaching a document. +
ECJU helpline
020 7215 4594
+ + Find out about call charges (opens in new tab)""" SUBMIT_BUTTON = "Save and continue" class Options: @@ -141,12 +144,16 @@ class Description: class IsControlled: TITLE = "Is the product on the control list?" DESCRIPTION = ( - "Products that aren't on the " + PERMISSION_FINDER_LINK + " may be affected by [military end use controls]" - "(https://www.gov.uk/guidance/export-controls-military-goods-software-and-technology), " - "[current trade sanctions and embargoes]" - "(https://www.gov.uk/guidance/current-arms-embargoes-and-other-restrictions) or " - "[weapons of mass destruction controls](https://www.gov.uk/guidance/supplementary-wmd-end-use-controls). " - "If the product isn't subject to any controls, you'll get a no licence required (NLR) document from ECJU." + 'Products that aren\'t on the control list' + 'may be affected by ' + 'military end use controls, ' + 'current trade sanctions and embargoes or ' + "weapons of mass destruction controls. If the product isn't subject to any controls, " + "you'll get a no licence required (NLR) document from ECJU." ) CLC_REQUIRED = ( "Products that aren't on the " + PERMISSION_FINDER_LINK + " may be affected by [military end use controls]" diff --git a/lite_forms/helpers.py b/lite_forms/helpers.py index c77acc4075..de45874013 100644 --- a/lite_forms/helpers.py +++ b/lite_forms/helpers.py @@ -1,7 +1,6 @@ import copy from collections.abc import MutableMapping -from markdown import markdown from lite_forms.components import FormGroup, Form, HiddenField, TreeNode @@ -155,20 +154,6 @@ def heading_used_as_label(components): return single_input -def convert_to_markdown(text): - if text: - text = "
".join([markdown(item.strip(), extensions=["nl2br"]) for item in text.split("\n\n")]) - # Replace leading (

) & trailing (

) p tags as they are not needed - text = text.replace("

", "") - text = text.replace("

", "") - text = text.replace( - "' + "return to application overview" + ) == lbl.text