Skip to content

Commit

Permalink
Merge pull request #2390 from uktrade/LTD-5962
Browse files Browse the repository at this point in the history
LTD-5962 Add previous application details screen for exporter f680 application
  • Loading branch information
markj0hnst0n authored Mar 10, 2025
2 parents 107580b + 2b3fcc3 commit 9217918
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class FormSteps:
APPLICATION_NAME = "APPLICATION_NAME"
HAS_MADE_PREVIOUS_APPLICATION = "HAS_MADE_PREVIOUS_APPLICATION"
EXCEPTIONAL_CIRCUMSTANCES = "EXCEPTIONAL_CIRCUMSTANCES"
EXCEPTIONAL_CIRCUMSTANCES_REASONS = "EXCEPTIONAL_CIRCUMSTANCES_REASONS"
PREVIOUS_APPLICATION = "PREVIOUS_APPLICATION"
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,44 @@ def get_layout_fields(self):
return ("name",)


class PreviousApplicationConfirm(BaseForm):
class Layout:
TITLE = "Have you made a previous application?"
TITLE_AS_LABEL_FOR = "has_made_previous_application"
SUBMIT_BUTTON_TEXT = "Continue"

has_made_previous_application = forms.TypedChoiceField(
choices=(
(True, "Yes"),
(False, "No"),
),
label=Layout.TITLE,
widget=forms.RadioSelect,
coerce=coerce_str_to_bool,
)

def get_layout_fields(self):
return ("has_made_previous_application",)


class PreviousApplicationsForm(BaseForm):
class Layout:
TITLE = "Previous applications"
SUBMIT_BUTTON_TEXT = "Continue"

previous_application_ecju_reference = forms.CharField(label="What is the ECJU reference number?")
previous_application_details = forms.CharField(
label="Can you provide more detail?",
help_text="For example if the products have been previously agreed or refused to the "
"end-user or country. Or if its for the same goods but to different destinations. "
"If possible provide the export trade licence number",
widget=forms.Textarea(attrs={"rows": "5"}),
)

def get_layout_fields(self):
return ("previous_application_ecju_reference", "previous_application_details")


class ExceptionalCircumstancesForm(BaseForm):
class Layout:
TITLE = "Do you have exceptional circumstances that mean you need F680 approval in less than 30 days?"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from exporter.f680.application_sections.general_application_details.forms import (
ApplicationNameForm,
PreviousApplicationConfirm,
PreviousApplicationsForm,
ExceptionalCircumstancesForm,
ExplainExceptionalCircumstancesForm,
)
Expand Down Expand Up @@ -70,6 +72,15 @@ def force_exceptional_circumstances(goto_step, post_to_step):
)


@pytest.fixture
def force_has_made_previous_application(goto_step, post_to_step):
goto_step(FormSteps.HAS_MADE_PREVIOUS_APPLICATION)
post_to_step(
FormSteps.HAS_MADE_PREVIOUS_APPLICATION,
{"has_made_previous_application": True},
)


@pytest.fixture
def mock_f680_application_get_existing_data(requests_mock, data_f680_case):
data_f680_case["application"] = {
Expand All @@ -85,6 +96,20 @@ def mock_f680_application_get_existing_data(requests_mock, data_f680_case):
"question": "What is the name of the application?",
"datatype": "string",
},
{
"key": "previous_application_ecju_reference",
"answer": "123456",
"raw_answer": "123456",
"question": "What is the ECJU reference number?",
"datatype": "string",
},
{
"key": "previous_application_details",
"answer": "some info",
"raw_answer": "some info",
"question": "Can you provide more detail?",
"datatype": "string",
},
{
"key": "is_exceptional_circumstances",
"answer": "Yes",
Expand Down Expand Up @@ -182,7 +207,17 @@ def test_GET_no_organisation_allowed(
@pytest.mark.parametrize(
"step, data, expected_next_form",
(
(FormSteps.APPLICATION_NAME, {"name": "some application name"}, ExceptionalCircumstancesForm),
(FormSteps.APPLICATION_NAME, {"name": "some application name"}, PreviousApplicationConfirm),
(
FormSteps.HAS_MADE_PREVIOUS_APPLICATION,
{"has_made_previous_application": True},
PreviousApplicationsForm,
),
(
FormSteps.PREVIOUS_APPLICATION,
{"previous_application_ecju_reference": "123", "previous_application_details": "some info"},
ExceptionalCircumstancesForm,
),
(
FormSteps.EXCEPTIONAL_CIRCUMSTANCES,
{"is_exceptional_circumstances": True},
Expand All @@ -198,6 +233,7 @@ def test_POST_to_step_success(
post_to_step,
goto_step,
mock_f680_application_get,
force_has_made_previous_application,
):
goto_step(step)
response = post_to_step(
Expand Down Expand Up @@ -273,6 +309,14 @@ def test_POST_submit_wizard_success(
FormSteps.APPLICATION_NAME,
{"name": "some test app"},
)
response = post_to_step(
FormSteps.HAS_MADE_PREVIOUS_APPLICATION,
{"has_made_previous_application": True},
)
response = post_to_step(
FormSteps.PREVIOUS_APPLICATION,
{"previous_application_ecju_reference": "123456", "previous_application_details": "some info"},
)
response = post_to_step(
FormSteps.EXCEPTIONAL_CIRCUMSTANCES,
{"is_exceptional_circumstances": True},
Expand All @@ -294,7 +338,6 @@ def test_POST_submit_wizard_success(
"sections": {
"general_application_details": {
"label": "General application details",
"type": "single",
"fields": [
{
"key": "name",
Expand All @@ -303,6 +346,27 @@ def test_POST_submit_wizard_success(
"question": "Name the application",
"datatype": "string",
},
{
"key": "has_made_previous_application",
"answer": "Yes",
"raw_answer": True,
"question": "Have you made a previous application?",
"datatype": "boolean",
},
{
"key": "previous_application_ecju_reference",
"answer": "123456",
"raw_answer": "123456",
"question": "What is the ECJU reference number?",
"datatype": "string",
},
{
"key": "previous_application_details",
"answer": "some info",
"raw_answer": "some info",
"question": "Can you provide more detail?",
"datatype": "string",
},
{
"key": "is_exceptional_circumstances",
"answer": "Yes",
Expand All @@ -325,7 +389,8 @@ def test_POST_submit_wizard_success(
"datatype": "string",
},
],
},
"type": "single",
}
},
}
}
Expand All @@ -334,7 +399,16 @@ def test_POST_submit_wizard_success(
"step, expected_form, expected_initial",
(
(FormSteps.APPLICATION_NAME, ApplicationNameForm, {"name": "my first F680"}),
(FormSteps.EXCEPTIONAL_CIRCUMSTANCES, ExceptionalCircumstancesForm, {"is_exceptional_circumstances": True}),
(
FormSteps.PREVIOUS_APPLICATION,
PreviousApplicationsForm,
{"previous_application_ecju_reference": "123456", "previous_application_details": "some info"},
),
(
FormSteps.EXCEPTIONAL_CIRCUMSTANCES,
ExceptionalCircumstancesForm,
{"is_exceptional_circumstances": True},
),
(
FormSteps.EXCEPTIONAL_CIRCUMSTANCES_REASONS,
ExplainExceptionalCircumstancesForm,
Expand All @@ -355,6 +429,7 @@ def test_GET_with_existing_data_success(
f680_application_wizard_url,
goto_step,
force_exceptional_circumstances,
force_has_made_previous_application,
):
response = goto_step(step)
assert response.status_code == 200
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
from exporter.f680.application_sections.views import F680ApplicationSectionWizard

from .constants import FormSteps
from .forms import ApplicationNameForm, ExceptionalCircumstancesForm, ExplainExceptionalCircumstancesForm
from .forms import (
ApplicationNameForm,
PreviousApplicationConfirm,
PreviousApplicationsForm,
ExceptionalCircumstancesForm,
ExplainExceptionalCircumstancesForm,
)


def is_exceptional_circumstances(wizard):
cleaned_data = wizard.get_cleaned_data_for_step(FormSteps.EXCEPTIONAL_CIRCUMSTANCES) or {}
return cleaned_data.get("is_exceptional_circumstances", False)


def has_made_previous_application(wizard):
cleaned_data = wizard.get_cleaned_data_for_step(FormSteps.HAS_MADE_PREVIOUS_APPLICATION) or {}
return cleaned_data.get("has_made_previous_application", False)


class GeneralApplicationDetailsView(F680ApplicationSectionWizard):
form_list = [
(FormSteps.APPLICATION_NAME, ApplicationNameForm),
(FormSteps.HAS_MADE_PREVIOUS_APPLICATION, PreviousApplicationConfirm),
(FormSteps.PREVIOUS_APPLICATION, PreviousApplicationsForm),
(FormSteps.EXCEPTIONAL_CIRCUMSTANCES, ExceptionalCircumstancesForm),
(FormSteps.EXCEPTIONAL_CIRCUMSTANCES_REASONS, ExplainExceptionalCircumstancesForm),
]
condition_dict = {
FormSteps.EXCEPTIONAL_CIRCUMSTANCES_REASONS: is_exceptional_circumstances,
FormSteps.PREVIOUS_APPLICATION: has_made_previous_application,
}
section = "general_application_details"
section_label = "General application details"

0 comments on commit 9217918

Please sign in to comment.