Skip to content

Commit

Permalink
Merge pull request #2253 from uktrade/LTD-5660-pre-populate-review-co…
Browse files Browse the repository at this point in the history
…mbine-licence-conditions

[LTD-5660] Ensure all OGD advice present at LU advice consolidation and refactor consolidation views
  • Loading branch information
currycoder authored Dec 9, 2024
2 parents df66c55 + 3106834 commit 867f322
Show file tree
Hide file tree
Showing 25 changed files with 1,887 additions and 404 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ jobs:
environment:
<<: *common_env_vars
PIPENV_DOTENV_LOCATION: tests.caseworker.env
PYTEST_ADDOPTS: unit_tests/caseworker lite_forms/tests.py --capture=no --nomigrations
PYTEST_ADDOPTS: caseworker unit_tests/caseworker lite_forms/tests.py --capture=no --nomigrations
FILE_UPLOAD_HANDLERS: django.core.files.uploadhandler.MemoryFileUploadHandler,django.core.files.uploadhandler.TemporaryFileUploadHandler
steps:
- backend_unit_tests:
Expand Down
37 changes: 27 additions & 10 deletions caseworker/advice/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,27 @@
FCDO_TEAM = "FCO"
LICENSING_UNIT_TEAM = "LICENSING_UNIT"
MOD_ECJU_TEAM = "MOD_ECJU"
MOD_DI_TEAM = "MOD_DI"
MOD_DSR_TEAM = "MOD_DSR"
MOD_DSTL_TEAM = "MOD_DSTL"
MOD_CAPPROT_TEAM = "MOD_CAPPROT"
MOD_CONSOLIDATE_TEAMS = [
"MOD_DI",
"MOD_DSR",
"MOD_DSTL",
"MOD_CAPPROT",
MOD_DI_TEAM,
MOD_DSR_TEAM,
MOD_DSTL_TEAM,
MOD_CAPPROT_TEAM,
]
MOD_TEAMS = [MOD_ECJU_TEAM, *MOD_CONSOLIDATE_TEAMS]
LU_CONSOLIDATE_TEAMS = [FCDO_TEAM, MOD_ECJU_TEAM]
NCSC_TEAM = "NCSC"
OGD_TEAMS = [
OGD_TEAMS_EXCLUDING_MOD = [
*DESNZ_TEAMS,
FCDO_TEAM,
*MOD_TEAMS,
NCSC_TEAM,
]
OGD_TEAMS = [
*OGD_TEAMS_EXCLUDING_MOD,
*MOD_TEAMS,
]

# Flags
LU_COUNTERSIGN_REQUIRED_ID = "bbf29b42-0aae-4ebc-b77a-e502ddea30a8" # /PS-IGNORE
Expand Down Expand Up @@ -188,6 +194,13 @@ def group_advice_by_team(advice):
return result


def group_advice_by_team_and_decision(advice):
result = defaultdict(list)
for item in advice:
result[f"{item['team']['id']}-{item['type']['key']}"].append(item)
return result


def get_advice_to_countersign(advice, caseworker):
advice_levels_to_countersign = [constants.AdviceLevel.USER]

Expand Down Expand Up @@ -269,16 +282,20 @@ def get_advice_to_consolidate(advice, user_team_alias):
"""

if user_team_alias == LICENSING_UNIT_TEAM:
# LU needs to review the consolidated advice given by MOD which is at team level
user_team_advice = filter_advice_by_level(advice, [constants.AdviceLevel.USER, constants.AdviceLevel.TEAM])
advice_from_teams = filter_advice_by_teams(user_team_advice, LU_CONSOLIDATE_TEAMS)
lu_consolidate_teams = OGD_TEAMS.copy()
mod_ecju_in_advice = any(advice["team"]["alias"] == MOD_ECJU_TEAM for advice in user_team_advice)
# If MOD ECJU advice is present, this will supersede all MOD advice
if mod_ecju_in_advice:
lu_consolidate_teams = [*OGD_TEAMS_EXCLUDING_MOD, MOD_ECJU_TEAM]
advice_from_teams = filter_advice_by_teams(user_team_advice, lu_consolidate_teams)
elif user_team_alias == MOD_ECJU_TEAM:
user_advice = filter_advice_by_level(advice, [constants.AdviceLevel.USER])
advice_from_teams = filter_advice_by_teams(user_advice, MOD_CONSOLIDATE_TEAMS)
else:
raise Exception(f"Consolidate/combine operation not allowed for team {user_team_alias}")

return group_advice_by_user(advice_from_teams)
return group_advice_by_team_and_decision(advice_from_teams)


def order_by_party_type(all_advice):
Expand Down
4 changes: 2 additions & 2 deletions caseworker/advice/templates/advice/advice_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<table id="table-licenceable-products" class="govuk-table advice-table">
{% if decision == 'approve' or decision == 'proviso' %}
<h2 class="govuk-!-font-weight-bold govuk-body govuk-!-padding-2 app-advice-recommendation-heading app-bg-colour--green">
{% if team %} Approved by {{ user.team.name }} {% else %} Approved by {{ user|full_name }} {% endif %}
{% if team %} Approved by {{ advice.0.team.name }} {% else %} Approved by {{ user|full_name }} {% endif %}
<span class="govuk-!-font-weight-regular app-advice-recommendation-heading__additional_details">{{ advice.0.created_at|parse_date|date:"d F Y" }}</span>
</h2>
{% elif decision == 'refuse' %}
<h2 class="govuk-heading-m app-bg-colour--red govuk-!-padding-2">
{% if team %} Refused by {{ user.team.name }} {% else %} Refused by {{ user|full_name }} {% endif %}
{% if team %} Refused by {{ advice.0.team.name }} {% else %} Refused by {{ user|full_name }} {% endif %}
</h2>
{% endif %}
<thead class="govuk-table__head">
Expand Down
Loading

0 comments on commit 867f322

Please sign in to comment.