Skip to content

Commit

Permalink
lint fixes and removed mark_down method
Browse files Browse the repository at this point in the history
  • Loading branch information
depsiatwal committed Oct 30, 2024
1 parent 31a862b commit 2e76b97
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 62 deletions.
6 changes: 4 additions & 2 deletions exporter/applications/forms/questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)
)
],
),
Expand Down
19 changes: 14 additions & 5 deletions exporter/apply_for_a_licence/forms/trade_control_licence.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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."
),
),
],
)
Expand Down Expand Up @@ -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 <a class="govuk-link govuk-link--no-visited-state" rel="noreferrer noopener" target="_blank" href="https://www.gov.uk/guidance/export-controls-military-goods-software-and-technology#trade-controls-and-arranging-sales-or-movements">trade control product categories</a>."""
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 <a class="govuk-link govuk-link--no-visited-state" '
f'rel="noreferrer noopener" target="_blank" href="{guidence_url}">'
"trade control product categories</a>."
)

options = [
Option(product_category["key"], product_category["value"], hint_text_map.get(product_category["key"]))
Expand Down
6 changes: 4 additions & 2 deletions exporter/apply_for_a_licence/forms/triage_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
41 changes: 22 additions & 19 deletions exporter/compliance/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br>Columns must start from column A and be in the following order:<br><ul>
<li>Licence number</li>
<li>Destination</li>
<li>End user type</li>
<li>Usage count</li>
<li>Period</li>
</ul><br>Licence number must be in one of the following formats:<br><ul>
<li>GBOXX20XX/XXXXX. For example GBOIE2020/00001)</li>
<li>GBOXX20XX/XXXXX/X for amended licences. For example GBOIE2020/00001/A</li>
</ul><br>Destination names must be entered exactly as they appear on the licence.<br><br>End user type must be one of the following, entered exactly as shown here:<br><ul>
<li>Government</li>
<li>Commercial</li>
<li>Pvt Indiv</li>
<li>Other</li>
</ul><br>Usage count must be a positive integer.<br><br>Period must be in the following format, entered exactly as shown with YY replaced with the last 2 digits of the year:<br><ul>
<li>01-JAN-YY to 31-DEC-YY</li>
</ul>
"""
FORMATTING_HELP_DETAILS = (
"The first row must contain column headers, or be blank."
"It must not contain returns data.<br>Columns must start from column A and be in the following order:<br><ul>"
"<li>Licence number</li>"
"<li>Destination</li>"
"<li>End user type</li>"
"<li>Usage count</li>"
"<li>Period</li>"
"</ul><br>Licence number must be in one of the following formats:<br><ul>"
"<li>GBOXX20XX/XXXXX. For example GBOIE2020/00001)</li>"
"<li>GBOXX20XX/XXXXX/X for amended licences. For example GBOIE2020/00001/A</li>"
"</ul><br>Destination names must be entered exactly as they appear on the licence."
"<br><br>End user type must be one of the following, entered exactly as shown here:<br><ul>"
"<li>Government</li>"
"<li>Commercial</li>"
"<li>Pvt Indiv</li>"
"<li>Other</li>"
"</ul><br>Usage count must be a positive integer."
"<br><br>Period must be in the following format, entered exactly as shown with YY replaced with the last 2 digits of the year:<br><ul>"
"<li>01-JAN-YY to 31-DEC-YY</li>"
"</ul>"
)
return FormGroup(
[
Form(
Expand Down
15 changes: 11 additions & 4 deletions exporter/goods/forms/goods.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
TextArea,
TextInput,
)
from lite_forms.helpers import convert_to_markdown
from lite_forms.styles import ButtonStyle, HeadingStyle


Expand Down Expand Up @@ -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.<br /> 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."
"<br /> This is required in order to process the application."
)

return Form(
title=DocumentAvailabilityForm.TITLE,
Expand Down Expand Up @@ -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.<br>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.<br>Do not attach a document that’s above OFFICIAL-SENSITIVE.<br>The file must be smaller than 50MB."""
DESCRIPTION = (
"Upload a DOCX, DOC, PDF, PNG, JPEG or ODT file.<br>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."
"<br>Do not attach a document that’s above OFFICIAL-SENSITIVE.<br>The file must be smaller than 50MB."
)

return Form(
title=AttachDocumentForm.TITLE,
Expand Down Expand Up @@ -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(
Expand Down
10 changes: 6 additions & 4 deletions lite_content/lite_exporter_frontend/compliance.py
Original file line number Diff line number Diff line change
@@ -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).<br>
You must submit open licence returns for:<br>
- Open Individual Export Licences (OIELs)<br> - Open Individual Trade Control Licences (OITCLs)<br> - 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).<br>"
" You must submit open licence returns for:<br> - Open Individual Export Licences (OIELs)<br>"
"- Open Individual Trade Control Licences (OITCLs)<br> - Open General Export Licences (OGELs)<br> - Open General Trade Control Licences (OGTCLs)"
)
BUTTON = "Next"


Expand Down
25 changes: 16 additions & 9 deletions lite_content/lite_exporter_frontend/goods.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ class DocumentAvailabilityForm:

class DocumentSensitivityForm:
TITLE = "Is the document rated above OFFICIAL-SENSITIVE?"
ECJU_HELPLINE = """<strong><noscript>If the answer is No;</noscript></strong><br>Contact ECJU to arrange a more secure way to send this document.<br>You can continue with the application without attaching a document.<br><strong>ECJU helpline</strong><br />
020 7215 4594<br /> <a class="govuk-link govuk-link--no-visited-state" rel="noreferrer noopener" target="_blank" href="https://www.gov.uk/call-charges">Find out about call charges (opens in new tab)</a>
"""
ECJU_HELPLINE = """<strong><noscript>If the answer is No;</noscript></strong>
<br>Contact ECJU to arrange a more secure way to send this document.
<br>You can continue with the application without attaching a document.
<br><strong>ECJU helpline</strong><br />020 7215 4594<br />
<a class="govuk-link govuk-link--no-visited-state" rel="noreferrer noopener" target="_blank" href="https://www.gov.uk/call-charges">
Find out about call charges (opens in new tab)</a>"""
SUBMIT_BUTTON = "Save and continue"

class Options:
Expand All @@ -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 <a class="govuk-link govuk-link--no-visited-state" '
'rel="noreferrer noopener" target="_blank" href="">control list</a>'
'may be affected by <a class="govuk-link govuk-link--no-visited-state" '
'rel="noreferrer noopener" target="_blank" href="https://www.gov.uk/guidance/export-controls-military-goods-software-and-technology"> '
'military end use controls</a>, <a class="govuk-link govuk-link--no-visited-state" rel="noreferrer noopener" '
'target="_blank" href="https://www.gov.uk/guidance/current-arms-embargoes-and-other-restrictions">'
'current trade sanctions and embargoes</a> or <a class="govuk-link govuk-link--no-visited-state" '
'rel="noreferrer noopener" target="_blank" href="https://www.gov.uk/guidance/supplementary-wmd-end-use-controls">'
"weapons of mass destruction controls</a>. 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]"
Expand Down
15 changes: 0 additions & 15 deletions lite_forms/helpers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import copy
from collections.abc import MutableMapping

from markdown import markdown

from lite_forms.components import FormGroup, Form, HiddenField, TreeNode

Expand Down Expand Up @@ -155,20 +154,6 @@ def heading_used_as_label(components):
return single_input


def convert_to_markdown(text):
if text:
text = "<br>".join([markdown(item.strip(), extensions=["nl2br"]) for item in text.split("\n\n")])
# Replace leading (<p>) & trailing (</p>) p tags as they are not needed
text = text.replace("<p>", "")
text = text.replace("</p>", "")
text = text.replace(
"<a", '<a class="govuk-link govuk-link--no-visited-state" rel="noreferrer noopener" target="_blank"'
)
return text
else:
return None


def handle_lists(data):
"""
By default get() returns only one value, we use getlist() to return multiple values
Expand Down
3 changes: 1 addition & 2 deletions lite_forms/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
Option,
BackLink,
HiddenField,
NumberInput,
RadioButtons,
FileUpload,
)
Expand Down Expand Up @@ -233,7 +232,7 @@ def test_multiple_user_inputs_no_title_label(self):
form = Form(
questions=[
TextInput("abc"),
NumberInput("def"),
TextInput("def"),
]
)
self.assertIsNone(form.single_form_element)
Expand Down
12 changes: 12 additions & 0 deletions unit_tests/exporter/applications/test_components.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from exporter.applications.components import footer_label


def test_footer_label(data_standard_case):
application_id = data_standard_case["case"]["data"]["id"]
lbl = footer_label(application_id)

assert (
'Or <a class="govuk-link govuk-link--no-visited-state"'
f' rel="noreferrer noopener" target="_blank" href="/applications/{application_id}/task-list/">'
"return to application overview</a>"
) == lbl.text

0 comments on commit 2e76b97

Please sign in to comment.