-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2352 from uktrade/LTD-5889-f680s-exporter-general…
…-application-details [LTD-5889] F680s exporter general application details
- Loading branch information
Showing
33 changed files
with
981 additions
and
369 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
version: 2.1 | ||
|
||
orbs: | ||
browser-tools: circleci/[email protected] | ||
browser-tools: circleci/[email protected] # /PS-IGNORE | ||
|
||
parameters: | ||
run_ui_tests: | ||
|
@@ -131,7 +131,7 @@ commands: | |
- run: | ||
name: Clone API | ||
command: | | ||
git clone [email protected]:uktrade/lite-api.git | ||
git clone [email protected]:uktrade/lite-api.git # /PS-IGNORE | ||
cd lite-api | ||
git checkout $(python ../which_branch.py <<parameters.api_branch>>) | ||
- run: | ||
|
@@ -252,7 +252,7 @@ jobs: | |
environment: | ||
<<: *common_env_vars | ||
PIPENV_DOTENV_LOCATION: tests.exporter.env | ||
PYTEST_ADDOPTS: unit_tests/exporter --capture=no --nomigrations | ||
PYTEST_ADDOPTS: exporter unit_tests/exporter --capture=no --nomigrations | ||
FILE_UPLOAD_HANDLERS: django.core.files.uploadhandler.MemoryFileUploadHandler,django.core.files.uploadhandler.TemporaryFileUploadHandler | ||
steps: | ||
- backend_unit_tests: | ||
|
@@ -266,7 +266,7 @@ jobs: | |
environment: | ||
<<: *common_env_vars | ||
PIPENV_DOTENV_LOCATION: tests.exporter.env | ||
PYTEST_ADDOPTS: unit_tests/core --capture=no --nomigrations | ||
PYTEST_ADDOPTS: core unit_tests/core --capture=no --nomigrations | ||
FILE_UPLOAD_HANDLERS: django.core.files.uploadhandler.MemoryFileUploadHandler,django.core.files.uploadhandler.TemporaryFileUploadHandler | ||
steps: | ||
- backend_unit_tests: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from unittest import mock | ||
|
||
from core.wizard.payloads import get_questions_data, get_cleaned_data | ||
|
||
|
||
class TestGetQuestionsData: | ||
|
||
def test_get_questions_data_no_cleaned_data(self): | ||
form = mock.Mock() | ||
form.cleaned_data = None | ||
assert get_questions_data(form) == {} | ||
|
||
def test_get_questions_data_form_with_declared_fields(self): | ||
form = mock.Mock() | ||
form.cleaned_data.return_value = {"cleaned": "data"} | ||
mock_field = mock.Mock() | ||
mock_field.label = "Name" | ||
form.declared_fields = { | ||
"name": mock_field, | ||
} | ||
assert get_questions_data(form) == {"name": "Name"} | ||
|
||
|
||
class TestGetCleanedData: | ||
|
||
def test_get_cleaned_data(self): | ||
form = mock.Mock() | ||
form.cleaned_data = {"some": "value"} | ||
assert get_cleaned_data(form) == {"some": "value"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# pylint: disable=unused-wildcard-import,wildcard-import | ||
from unit_tests.conftest import * | ||
from unit_tests.exporter.conftest import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
4 changes: 4 additions & 0 deletions
4
exporter/f680/application_sections/general_application_details/constants.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class FormSteps: | ||
APPLICATION_NAME = "APPLICATION_NAME" | ||
EXCEPTIONAL_CIRCUMSTANCES = "EXCEPTIONAL_CIRCUMSTANCES" | ||
EXCEPTIONAL_CIRCUMSTANCES_REASONS = "EXCEPTIONAL_CIRCUMSTANCES_REASONS" |
98 changes: 98 additions & 0 deletions
98
exporter/f680/application_sections/general_application_details/forms.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
from datetime import datetime | ||
from django import forms | ||
from django.template.loader import render_to_string | ||
|
||
from crispy_forms_gds.fields import DateInputField | ||
from crispy_forms_gds.layout.content import HTML | ||
|
||
from core.common.forms import BaseForm | ||
from core.forms.utils import coerce_str_to_bool | ||
|
||
from exporter.core.validators import ( | ||
FutureDateValidator, | ||
RelativeDeltaDateValidator, | ||
) | ||
|
||
|
||
class ApplicationNameForm(BaseForm): | ||
class Layout: | ||
TITLE = "Name the application" | ||
TITLE_AS_LABEL_FOR = "name" | ||
SUBMIT_BUTTON_TEXT = "Continue" | ||
|
||
name = forms.CharField( | ||
label=Layout.TITLE, | ||
help_text="Give the application a reference name so you can refer back to it when needed", | ||
) | ||
|
||
def get_layout_fields(self): | ||
return ("name",) | ||
|
||
|
||
class ExceptionalCircumstancesForm(BaseForm): | ||
class Layout: | ||
TITLE = "Do you have exceptional circumstances that mean you need F680 approval in less than 30 days?" | ||
TITLE_AS_LABEL_FOR = "is_exceptional_circumstances" | ||
SUBMIT_BUTTON_TEXT = "Continue" | ||
|
||
is_exceptional_circumstances = forms.TypedChoiceField( | ||
choices=( | ||
(True, "Yes"), | ||
(False, "No"), | ||
), | ||
label="Do you have exceptional circumstances that mean you need F680 approval in less than 30 days?", | ||
widget=forms.RadioSelect, | ||
coerce=coerce_str_to_bool, | ||
) | ||
|
||
def get_layout_fields(self): | ||
return ( | ||
"is_exceptional_circumstances", | ||
HTML.details( | ||
"Help with exceptional circumstances", | ||
render_to_string("f680/forms/help_exceptional_circumstances.html"), | ||
), | ||
) | ||
|
||
|
||
class ExplainExceptionalCircumstancesForm(BaseForm): | ||
class Layout: | ||
TITLE = "Explain your exceptional circumstances" | ||
SUBMIT_BUTTON_TEXT = "Save and continue" | ||
|
||
exceptional_circumstances_date = DateInputField( | ||
label="When do you need your F680 approval?", | ||
validators=[ | ||
FutureDateValidator("Date must be in the future"), | ||
RelativeDeltaDateValidator("Date must be within 30 days", days=30), | ||
], | ||
) | ||
exceptional_circumstances_reason = forms.CharField( | ||
label="Why do you need approval in less than 30 days?", | ||
widget=forms.Textarea(attrs={"rows": "5"}), | ||
) | ||
|
||
def __init__(self, *args, **kwargs): | ||
# We have to do some coercion from string to datetime object here due to JSON serialization | ||
if ( | ||
"initial" in kwargs | ||
and "exceptional_circumstances_date" in kwargs["initial"] | ||
and isinstance(kwargs["initial"]["exceptional_circumstances_date"], str) | ||
): | ||
kwargs["initial"]["exceptional_circumstances_date"] = datetime.fromisoformat( | ||
kwargs["initial"]["exceptional_circumstances_date"] | ||
) | ||
super().__init__(*args, **kwargs) | ||
|
||
def clean(self): | ||
# We have to do some coercion from datetime object to string here due to JSON serialization | ||
cleaned_data = super().clean() | ||
if "exceptional_circumstances_date" in cleaned_data: | ||
cleaned_data["exceptional_circumstances_date"] = cleaned_data["exceptional_circumstances_date"].isoformat() | ||
return cleaned_data | ||
|
||
def get_layout_fields(self): | ||
return ( | ||
"exceptional_circumstances_date", | ||
"exceptional_circumstances_reason", | ||
) |
Empty file.
Oops, something went wrong.