diff --git a/common/tests/test_models.py b/common/tests/test_models.py index 137705ca7..e65c34b0e 100644 --- a/common/tests/test_models.py +++ b/common/tests/test_models.py @@ -409,7 +409,7 @@ def test_get_description_dates(description_factory, date_ranges): def test_trackedmodel_get_url( trackedmodel_factory, - valid_user_client, + client_with_current_workbasket, mock_quota_api_no_data, ): """Verify get_url() returns something sensible and doesn't crash.""" @@ -428,7 +428,7 @@ def test_trackedmodel_get_url( # Verify URL is not local assert not urlparse(url).netloc - response = valid_user_client.get(url) + response = client_with_current_workbasket.get(url) assert response.status_code == 200 diff --git a/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja b/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja index f8514ccba..3326bb00b 100644 --- a/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja +++ b/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja @@ -1,4 +1,12 @@ {% set table_rows = [] %} +{% set table_head = [ + {"text": "Order number"}, + {"text": "Relationship type"}, + {"text": "Co-efficient"}, + ] %} +{% if sub_quota_associations %} + {{ table_head.append({"text": "Actions"}) or "" }} +{% endif %} {% for object in sub_quota_associations %} {% set sub_quota_link %} Sub-quotas +

The following sub-quota definitions exist for definition periods on Quota {{ quota.order_number}}.

{% for object in sub_quotas %} {% set definition_link -%}
{{ object.sub_quota.sid }} @@ -11,7 +12,7 @@ {{ object.sub_quota.order_number.order_number }} {% endset %} {% set actions_html %} - Edit + Edit
Delete {% endset %} @@ -41,6 +42,7 @@ }) }} {% elif main_quotas %}

Main quotas

+

Quota {{ quota.order_number }} has definition periods which are sub-quotas of the following quota definitions. To edit the associations, go to the main quota's data page.

{% for object in main_quotas %} {% set definition_link -%} {{ object.main_quota.sid }} @@ -48,11 +50,6 @@ {% set main_quota_link -%} {{ object.main_quota.order_number.order_number }} {% endset %} - {% set actions_html %} - Edit -
- Delete - {% endset %} {{ table_rows.append([ {"text": definition_link }, {"text": main_quota_link }, @@ -60,7 +57,6 @@ {"text": "{:%d %b %Y}".format(object.main_quota.version_at(request.user.current_workbasket.transactions.last()).valid_between.upper) if object.main_quota.valid_between.upper else "-"}, {"text": object.get_sub_quota_relation_type_display() }, {"text": object.coefficient }, - {"text": actions_html }, ]) or "" }} {% endfor %} {{ govukTable({ @@ -71,7 +67,6 @@ {"text": "End date"}, {"text": "Relationship type"}, {"text": "Coefficient"}, - {"text": "Actions"}, ], "rows": table_rows }) }} diff --git a/quotas/views/definitions.py b/quotas/views/definitions.py index 08b93eb6c..33da960cf 100644 --- a/quotas/views/definitions.py +++ b/quotas/views/definitions.py @@ -3,6 +3,7 @@ from django.db.models import Q from django.http import HttpResponseRedirect from django.urls import reverse +from django.utils.decorators import method_decorator from django.utils.functional import cached_property from django.views.generic.list import ListView from rest_framework import permissions @@ -23,6 +24,7 @@ from quotas.models import QuotaBlocking from quotas.models import QuotaSuspension from workbaskets.models import WorkBasket +from workbaskets.views.decorators import require_current_workbasket from workbaskets.views.generic import CreateTaricCreateView from workbaskets.views.generic import CreateTaricDeleteView from workbaskets.views.generic import CreateTaricUpdateView @@ -36,6 +38,7 @@ class QuotaDefinitionViewset(viewsets.ReadOnlyModelViewSet): search_fields = ["sid", "order_number__order_number", "description"] +@method_decorator(require_current_workbasket, name="dispatch") class QuotaDefinitionList(SortingMixin, ListView): template_name = "quotas/definitions.jinja" model = models.QuotaDefinition