Skip to content

Commit

Permalink
Merge pull request #1903 from uktrade/uat
Browse files Browse the repository at this point in the history
prod release
  • Loading branch information
saruniitr authored Apr 18, 2024
2 parents 491a674 + a8972c5 commit 3581ef6
Show file tree
Hide file tree
Showing 21 changed files with 409 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ setuptools = "~=65.5.1"
rules="~=3.3.0"
django-extra-views = "~=0.14.0"
djangorestframework = "~=3.14.0"
django = "~=4.2.10"
django = "~=4.2.11"

[requires]
python_version = "3.9"
29 changes: 15 additions & 14 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

- [Python 3.9](https://www.python.org/downloads/release/python-39/)
- [Pipenv](https://pipenv.pypa.io/en/latest/)
- [Homebrew](https://brew.sh/)

### Installing

Expand Down Expand Up @@ -62,15 +63,21 @@ make run_exporter
- Set up your local config file:
- `make secrets`
- populate the newly created `caseworker.env` and `exporter.env` with values from Vault.
- As it states in the env file add the following to your to your /etc/hosts file:
```
127.0.0.1 caseworker
127.0.0.1 exporter
```
- Further information at https://kinsta.com/knowledgebase/edit-mac-hosts-file/
* Ensure docker is running
* Build and start docker images:
- If you haven't already done this for lite-api, set up a shared docker network:
- `docker network create lite` - shared network to allow API and frontend to communicate
- `docker network create lite` - shared network to allow API and frontend to communicate
- `docker-compose build` - build the container image
* Installation requirements
- install libmagic
- install libmagic with the `brew install libmagic` command.
#### Starting the service
Expand Down
9 changes: 2 additions & 7 deletions caseworker/advice/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ def can_ncsc_make_recommendation(user, case, queue_alias):


def can_desnz_make_recommendation(user, case, queue_alias):
# TODO: Remove BEIS queue aliases when DESNZ aliases in lite-api
if queue_alias not in (
services.DESNZ_CHEMICAL_CASES_TO_REVIEW,
services.DESNZ_NUCLEAR_CASES_TO_REVIEW,
"BEIS_CHEMICAL_CASES_TO_REVIEW",
"BEIS_NUCLEAR_CASES_TO_REVIEW",
):
return False
# TODO: Remove BEIS queue alias when DESNZ alias in lite-api
if queue_alias == services.DESNZ_NUCLEAR_CASES_TO_REVIEW or queue_alias == "BEIS_NUCLEAR_CASES_TO_REVIEW":
if queue_alias == services.DESNZ_NUCLEAR_CASES_TO_REVIEW:
return len(services.unassessed_trigger_list_goods(case)) == 0

return True
Expand All @@ -56,8 +52,7 @@ def can_user_make_recommendation(request, case):
return can_fcdo_make_recommendation(user, case, queue_alias)
if team in services.MOD_CONSOLIDATE_TEAMS:
return can_mod_make_recommendation(user, case, queue_alias)
# TODO: Remove BEIS team aliases when DESNZ aliases in lite-api
if team in services.DESNZ_TEAMS or team in services.BEIS_TEAMS:
if team in services.DESNZ_TEAMS:
return can_desnz_make_recommendation(user, case, queue_alias)
if team == services.NCSC_TEAM:
return can_ncsc_make_recommendation(user, case, queue_alias)
Expand Down
21 changes: 3 additions & 18 deletions caseworker/advice/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
DESNZ_CHEMICAL,
DESNZ_NUCLEAR,
]
# TODO: Remove BEIS team aliases when DESNZ team aliases in lite-api
BEIS_TEAMS = ["BEIS_CHEMICAL", "BEIS_NUCLEAR"]
FCDO_TEAM = "FCO"
LICENSING_UNIT_TEAM = "LICENSING_UNIT"
MOD_ECJU_TEAM = "MOD_ECJU"
Expand Down Expand Up @@ -542,17 +540,13 @@ def get_advice_tab_context(case, caseworker, queue_id):
"assess_trigger_list_products": False,
},
}
# TODO: Remove BEIS team aliases when DESNZ aliases in lite-api
if team_alias in (FCDO_TEAM, *MOD_CONSOLIDATE_TEAMS, *DESNZ_TEAMS, *BEIS_TEAMS, NCSC_TEAM):
# TODO: Remove BEIS queue aliases when DESNZ aliases in lite-api
if team_alias in (FCDO_TEAM, *MOD_CONSOLIDATE_TEAMS, *DESNZ_TEAMS, NCSC_TEAM):
if queue_alias in (
FCDO_CASES_TO_REVIEW_QUEUE,
FCDO_CPACC_CASES_TO_REVIEW_QUEUE,
*MOD_CONSOLIDATE_QUEUES,
DESNZ_CHEMICAL_CASES_TO_REVIEW,
DESNZ_NUCLEAR_CASES_TO_REVIEW,
"BEIS_CHEMICAL_CASES_TO_REVIEW",
"BEIS_NUCLEAR_CASES_TO_REVIEW",
NCSC_CASES_TO_REVIEW,
):
existing_advice = get_my_advice(case.advice, caseworker["id"])
Expand All @@ -565,18 +559,9 @@ def get_advice_tab_context(case, caseworker, queue_id):
context["buttons"]["move_case_forward"] = True

# DESNZ Nuclear need to assess products first before giving recommendation
# TODO: Remove BEIS team alias when DESNZ alias in lite-api
# TODO: Remove BEIS queue alias when DESNZ alias in lite-api
if (
(team_alias == DESNZ_NUCLEAR or team_alias == "BEIS_NUCLEAR")
and (queue_alias == DESNZ_NUCLEAR_CASES_TO_REVIEW or queue_alias == "BEIS_NUCLEAR_CASES_TO_REVIEW")
and not existing_advice
):
if (team_alias == DESNZ_NUCLEAR) and (queue_alias == DESNZ_NUCLEAR_CASES_TO_REVIEW) and not existing_advice:
context["buttons"]["assess_trigger_list_products"] = len(unassessed_trigger_list_goods(case)) > 0
# TODO: Remove BEIS queue alias when DESNZ queue alias in lite-api
elif queue_alias == FCDO_COUNTERSIGNING_QUEUE or (
queue_alias == DESNZ_NUCLEAR_COUNTERSIGNING or queue_alias == "BEIS_NUCLEAR_COUNTERSIGNING"
):
elif queue_alias == FCDO_COUNTERSIGNING_QUEUE or (queue_alias == DESNZ_NUCLEAR_COUNTERSIGNING):
advice_to_countersign = get_advice_to_countersign(case.advice, caseworker)
countersigned_by = get_countersigners(advice_to_countersign)

Expand Down
1 change: 0 additions & 1 deletion caseworker/core/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ def get_permissible_statuses(request, case):
if status["key"]
not in [
CaseStatusEnum.APPLICANT_EDITING,
CaseStatusEnum.CLOSED,
CaseStatusEnum.FINALISED,
CaseStatusEnum.REGISTERED,
CaseStatusEnum.CLC,
Expand Down
4 changes: 2 additions & 2 deletions caseworker/external_data/example.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
reference,name,address,notifying_government,final_destination,item_list_codes,item_description,consignee_name,end_use,field_one,field_two,field_n
ABC123,44,123 fake street,France,Germany,ABC123,Grapes,Fred Example,Used in car,value_one,value_two,value_n
reference,regime_reg_ref,name,address,notifying_government,country,item_list_codes,item_description,consignee_name,end_use,reason_for_refusal,spire_entity_id
DN2000/0000,AB-CD-EF-000,Organisation Name,"1000 Street Name, City Name",Country Name,Country Name,0A00100,Medium Size Widget,Example Name,Used in industry,Risk of outcome,123
4 changes: 3 additions & 1 deletion caseworker/external_data/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
app_name = "external_data"

urlpatterns = [
path("denials/upload/", views.DenialUploadView.as_view(), name="denials-upload"),
path(
"denials/add-by-csv/", views.DenialUploadView.as_view(), name="denials-add-by-csv"
), # TODO: rename back to "denials/upload/" and "denials-upload" when we are ready to release this to users
path("denials/<uuid:pk>/", views.DenialDetailView.as_view(), name="denial-detail"),
path("denials/<uuid:pk>/revoke/", views.DenialRevokeView.as_view(), name="denial-revoke"),
]
4 changes: 2 additions & 2 deletions example.caseworker.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ ALLOWED_HOSTS=*
ALLOWED_HOSTS=*
OAUTHLIB_INSECURE_TRANSPORT=True
GTM_ID=''
LITE_API_HAWK_KEY=

LITE_API_URL=http://host.docker.internal:8100
# comment above LITE_API_URL and uncomment below if running outside docker
Expand All @@ -27,12 +26,14 @@ TEST_TYPE_HEADLESS=False
TEST_SSO_EMAIL=<<FROM_VAULT>>
TEST_SSO_PASSWORD=<<FROM_VAULT>>
TEST_SSO_NAME=<<FROM_VAULT>>
TEST_EXPORTER_SSO_NAME=<<FROM_VAULT>>
EXPORTER_TEST_SSO_EMAIL=<<FROM_VAULT>>
EXPORTER_TEST_SSO_PASSWORD=<<FROM_VAULT>>

# AWS
AWS_S3_ENDPOINT_URL=http://s3:9000
AWS_ACCESS_KEY_ID=minio_username
AWS_REGION=eu-west-2
AWS_SECRET_ACCESS_KEY=minio_password
AWS_STORAGE_BUCKET_NAME=uploads

Expand All @@ -42,7 +43,6 @@ DJANGO_SECRET_KEY=DJANGO_SECRET_KEY

ENVIRONMENT=local

LITE_E2E_HAWK_KEY=LITE_E2E_HAWK_KEY
PERMISSIONS_FINDER_URL=

STATICFILES_STORAGE=django.contrib.staticfiles.storage.StaticFilesStorage
Expand Down
2 changes: 1 addition & 1 deletion exporter/applications/forms/export_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def route_of_goods_form():
"<br>"
+ "<details class='govuk-details' data-module='govuk-details'>"
+ "<summary class='govuk-details__summary'>"
+ "<span class='govuk-details__summary-text'>Help with airway bill and bill of landing</span>"
+ "<span class='govuk-details__summary-text'>Help with airway bill and bill of lading</span>"
+ "</summary>"
+ "<div class='govuk-details__text govuk'>"
+ "<p>"
Expand Down
2 changes: 1 addition & 1 deletion exporter/applications/forms/route_of_goods.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def route_of_goods_form(back_link):
"<br>"
+ "<details class='govuk-details' data-module='govuk-details'>"
+ "<summary class='govuk-details__summary'>"
+ "<span class='govuk-details__summary-text'>Help with airway bill and bill of landing</span>"
+ "<span class='govuk-details__summary-text'>Help with airway bill and bill of lading</span>"
+ "</summary>"
+ "<div class='govuk-details__text govuk'>"
+ "<p>"
Expand Down
12 changes: 8 additions & 4 deletions exporter/applications/helpers/check_your_answers.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _convert_standard_application(application, editable=False, is_summary=False)
product_location = {"Product location and journey": _get_product_location_and_journey(application)}
converted = {**product_location, **converted}

if has_incorporated_goods(application):
if has_ultimate_end_users(application) and has_incorporated_goods_on_application(application):
ultimate_end_users = [convert_party(item, application, editable) for item in application["ultimate_end_users"]]
converted[strings.ULTIMATE_END_USERS] = ultimate_end_users

Expand Down Expand Up @@ -706,9 +706,13 @@ def is_application_export_type_permanent(application):
return False if not application.get("export_type") else (application.get("export_type").get("key") == PERMANENT)


def has_incorporated_goods(application):
for good in application["goods"]:
if good["is_good_incorporated"]:
def has_ultimate_end_users(application):
return bool(application["ultimate_end_users"])


def has_incorporated_goods_on_application(application):
for goa in application["goods"]:
if goa.get("is_good_incorporated") or goa.get("is_onward_incorporated"):
return True

return False
Expand Down
2 changes: 1 addition & 1 deletion exporter/templates/applications/goods/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ <h1 class="govuk-heading-l">
</div>

<p class="govuk-body">
Where possible, please add items in the same order as they are shown on the end user undertaking document. This will help case officers process applications quickly.
Where possible, please add items in the same order as they are shown on the end-user undertaking <a class="govuk-link" href="https://www.gov.uk/government/publications/end-user-undertaking-euu-form" target=”_blank”>form</a> (opens in new tab). This will help case officers process applications quickly.
</p>

{% if application.status.key in 'applicant_editing,draft' %}
Expand Down
5 changes: 5 additions & 0 deletions exporter/templates/core/hub.html
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,9 @@ <h2 class="govuk-!-margin-top-0">
</div>
</div>
{% endif %}
<div class="govuk-grid-row">
<div class="govuk-body govuk-grid-column-two-thirds govuk-!-margin-top-5">
{% comment %}/PS-IGNORE{% endcomment %}If you or any of your colleagues have accessibility needs, tell us how we can improve your user experience. Contact <a href="mailto:[email protected]">[email protected]</a>.
</div>
</div>
{% endblock %}
6 changes: 2 additions & 4 deletions exporter/templates/includes/ecju-queries.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ <h3 class="govuk-heading-m">Open queries</h3>
{% for ecju_query in open_queries %}
<div class="app-ecju-query" id="open-ecju-query">
<div class="app-ecju-query__item">
<!-- TODO: Remove BEIS team alias when DESNZ alias in lite-api -->
{% if ecju_query.team.alias == "BEIS_CHEMICAL" or ecju_query.team.alias == "DESNZ_CHEMICAL" %}
{% if ecju_query.team.alias == "DESNZ_CHEMICAL" %}
<p class="app-ecju-query__heading">DESNZ Chemical</p>
<!-- TODO: Remove BEIS team alias when DESNZ alias in lite-api -->
{% elif ecju_query.team.alias == "BEIS_NUCLEAR" or ecju_query.team.alias == "DESNZ_NUCLEAR" %}
{% elif ecju_query.team.alias == "DESNZ_NUCLEAR" %}
<p class="app-ecju-query__heading">DESNZ Nuclear</p>
{% else %}
<p class="app-ecju-query__heading">{{ ecju_query.team.name }}</p>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"private": true,
"scripts": {
"build_exporter": "parcel build ./exporter/assets/javascripts/main.js ./exporter/assets/javascripts/cookie-policy-form.js --dist-dir exporter/assets/built --public-url /assets/",
"build_caseworker": "parcel build ./caseworker/assets/javascripts/{main,head,bookmarks,cookie-policy-form,beis,tau,tau-edit,tau-multiple-assessment-edit,case-filters,refusal-review-consolidate,search-products}.js --dist-dir caseworker/assets/built --public-url /assets/",
"build_caseworker": "parcel build ./caseworker/assets/javascripts/{main,head,bookmarks,cookie-policy-form,desnz,tau,tau-edit,tau-multiple-assessment-edit,case-filters,refusal-review-consolidate,search-products}.js --dist-dir caseworker/assets/built --public-url /assets/",
"watch_exporter": "PARCEL_WORKERS=0 parcel watch --port 8400 ./exporter/assets/javascripts/{main,head}.js ./exporter/assets/javascripts/cookie-policy-form.js --dist-dir exporter/assets/built --public-url /assets/",
"watch_caseworker": "PARCEL_WORKERS=0 parcel watch --port 8401 ./caseworker/assets/javascripts/{main,head,bookmarks,cookie-policy-form,search-cases,beis,tau,tau-edit,tau-multiple-assessment-edit,case-filters,refusal-review-consolidate,search-products}.js --dist-dir caseworker/assets/built --public-url /assets/",
"watch_caseworker": "PARCEL_WORKERS=0 parcel watch --port 8401 ./caseworker/assets/javascripts/{main,head,bookmarks,cookie-policy-form,search-cases,desnz,tau,tau-edit,tau-multiple-assessment-edit,case-filters,refusal-review-consolidate,search-products}.js --dist-dir caseworker/assets/built --public-url /assets/",
"watch": "rm -rf .parcel-cache && npm run build_exporter && npm run build_caseworker && concurrently 'npm run watch_exporter' 'npm run watch_caseworker'",
"build": "npm install --no-save && npm run build_all",
"build_all": "export NODE_ENV=production && concurrently 'npm run build_exporter' 'npm run build_caseworker'",
Expand Down
36 changes: 36 additions & 0 deletions unit_tests/caseworker/cases/views/test_change_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,42 @@ def test_change_status_GET_provides_finalise_status(
assert (CaseStatusEnum.FINALISED in statuses) == expected


@pytest.mark.parametrize(
"gov_user_type,expected",
[
("mock_gov_tau_user", False),
("mock_gov_fcdo_user", False),
("mock_gov_desnz_nuclear_user", False),
("mock_gov_lu_user", False),
("mock_gov_lu_super_user", True),
],
)
def test_closed_status_visible_to_specific_roles(
authorized_client,
change_status_url,
case_id,
gov_user_type,
expected,
request,
):
_ = request.getfixturevalue(gov_user_type)

response = authorized_client.get(change_status_url)
assert response.status_code == 200

assertTemplateUsed(response, "layouts/case.html")
context = response.context
assert context["case"].id == case_id

html = BeautifulSoup(response.content, "html.parser")
all_h1s = [elem.get_text().strip() for elem in html.find_all("h1")]
assert "Change case status" in all_h1s

# Only LU users get an option set the status as 'Finalised'
statuses = [item["value"] for item in html.find_all("option")]
assert (CaseStatusEnum.CLOSED in statuses) == expected


def test_change_status_success(
authorized_client,
case_url,
Expand Down
Loading

0 comments on commit 3581ef6

Please sign in to comment.