Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LTD: F680 Add recommendation #2376

Draft
wants to merge 3 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions caseworker/advice/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,23 @@ def post_approval_advice(request, case, data, level="user-advice"):
return response.json(), response.status_code


def post_f680_approval_advice(request, case, data, level="user-advice"):
json = [
{
"type": "proviso" if data.get("proviso", False) else "approve",
"text": data["approval_reasons"],
"proviso": data.get("proviso", ""),
"note": data.get("instructions_to_exporter", ""),
"footnote_required": True if data.get("footnote_details") else False,
"footnote": data.get("footnote_details", ""),
"denial_reasons": [],
}
]
response = client.post(request, f"/cases/{case['id']}/{level}/", json)
response.raise_for_status()
return response.json(), response.status_code


def post_refusal_advice(request, case, data, level="user-advice"):
json = [
{
Expand Down
2 changes: 2 additions & 0 deletions caseworker/advice/views/approval.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def get_context_data(self, **kwargs):
"Unexpected error adding approval advice",
)
def post_approval_advice(self, data):
if self.case['case_type']['reference']['key'] == 'f680':
return services.post_f680_approval_advice(self.request, self.case, data)
return services.post_approval_advice(self.request, self.case, data)

def get_payload(self, form_dict):
Expand Down
4 changes: 2 additions & 2 deletions caseworker/advice/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def caseworker(self):

@property
def goods(self):
for index, good_on_application in enumerate(self.case["data"]["goods"], start=1):
for index, good_on_application in enumerate(self.case["data"].get("goods", []), start=1):
good_on_application["line_number"] = index

return self.case["data"]["goods"]
return self.case["data"].get("goods", [])

def get_context(self, **kwargs):
return {}
Expand Down
2 changes: 1 addition & 1 deletion caseworker/advice/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class AdviceDetailView(LoginRequiredMixin, CaseTabsMixin, CaseContextMixin, DESN
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
my_advice = services.get_my_advice(self.case.advice, self.caseworker_id, self.caseworker["team"]["alias"])
nlr_products = services.filter_nlr_products(self.case["data"]["goods"])
nlr_products = services.filter_nlr_products(self.case["data"].get("goods", []))
advice_completed = services.unadvised_countries(self.caseworker, self.case) == {}
title = f"View recommendation for this case - {self.case.reference_code} - {self.case.organisation['name']}"

Expand Down
2 changes: 2 additions & 0 deletions caseworker/core/rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def get_logged_in_caseworker(request):

@rules.predicate
def has_available_sub_statuses(request, case):
if case.reference != "siel":
return False
return bool(get_case_sub_statuses(request, case["id"]))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a change going into api which should fix this here



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends 'layouts/case.html' %}


{% block details %}

<br>
<a id="make-recommendation-button" draggable="false" class="govuk-button govuk-button--primary" href="{% url 'cases:select_advice' queue_pk case.id %}">Make recommendation</a>

{% endblock %}
5 changes: 5 additions & 0 deletions caseworker/f680/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,9 @@
views.CaseDetailView.as_view(),
name="details",
),
path(
"recommendation/",
views.CaseRecommendationView.as_view(),
name="recommendation",
),
]
17 changes: 17 additions & 0 deletions caseworker/f680/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,20 @@ def get_context_data(self, **kwargs):
self.case["data"]["submitted_by"] = " ".join([submitted_by["first_name"], submitted_by["last_name"]])
context_data["case"] = self.case
return context_data


class CaseRecommendationView(LoginRequiredMixin, CaseworkerMixin, TemplateView):
template_name = "f680/case/recommendation/recommendation.html"

def setup(self, request, *args, **kwargs):
super().setup(request, *args, **kwargs)

self.case_id = str(kwargs["pk"])
self.case = get_case(request, self.case_id)
self.queue_id = kwargs["queue_pk"]
self.queue = get_queue(request, self.queue_id)

def get_context_data(self, **kwargs):
context_data = super().get_context_data(**kwargs)
context_data["case"] = self.case
return context_data