diff --git a/common/jinja2/layouts/detail.jinja b/common/jinja2/layouts/detail.jinja index 6356a88a6..d0a607a09 100644 --- a/common/jinja2/layouts/detail.jinja +++ b/common/jinja2/layouts/detail.jinja @@ -12,6 +12,13 @@ {% block content %}
Showing currently active measures.
{{ govukTable({ diff --git a/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja b/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja index a03d4147e..f8514ccba 100644 --- a/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja +++ b/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja @@ -1,33 +1,69 @@ {% set table_rows = [] %} -{% for quota_association in quota_associations %} +{% for object in sub_quota_associations %} {% set sub_quota_link %} - {{ quota_association.sub_quota.order_number }} + href="{{ url('quota-ui-detail', args=[object.sub_quota.order_number.sid]) }}"> + {{ object.sub_quota.order_number }} {% endset %} + {% set actions_html %} + Edit +No active sub-quotas.
- {% endif %} + {"text": "Actions"} + ], + "rows": table_rows + }) + }} + {% else %} +No active main or sub-quotas.
+ {% endif %} +There are no sub-quotas for this quota order number.
+There are no main or sub-quotas for this quota order number.
{% endif %} \ No newline at end of file diff --git a/quotas/tests/test_views.py b/quotas/tests/test_views.py index eb960c1a5..ca366c957 100644 --- a/quotas/tests/test_views.py +++ b/quotas/tests/test_views.py @@ -680,6 +680,7 @@ def test_quota_detail_sub_quota_tab( valid_user_client, date_ranges, mock_quota_api_no_data, + session_request_with_workbasket, ): quota_order_number = factories.QuotaOrderNumberFactory() current_definition = factories.QuotaDefinitionFactory.create( @@ -2010,7 +2011,7 @@ def test_quota_definition_view(client_with_current_workbasket): response = client_with_current_workbasket.get( reverse( "quota_definition-ui-list-filter", - kwargs={"sid": main_quota.sid, "quota_type": "sub_quotas"}, + kwargs={"sid": main_quota.sid, "quota_type": "quota_associations"}, ), ) assert response.status_code == 200 diff --git a/quotas/views.py b/quotas/views.py index af6bf09e3..d373a8a3f 100644 --- a/quotas/views.py +++ b/quotas/views.py @@ -240,12 +240,14 @@ def get_context_data(self, *args, **kwargs): f"{URLs.BASE_URL.value}quota_search?order_number={self.object.order_number}" ) - context[ - "quota_associations" - ] = QuotaAssociation.objects.latest_approved().filter( + context["sub_quota_associations"] = QuotaAssociation.objects.current().filter( main_quota=current_definition, ) + context["main_quota_associations"] = QuotaAssociation.objects.current().filter( + sub_quota=current_definition, + ) + context["blocking_period"] = ( QuotaBlocking.objects.filter(quota_definition=current_definition) .as_at_and_beyond(date.today()) @@ -314,6 +316,13 @@ def sub_quotas(self): .order_by("sub_quota__sid") ) + @property + def main_quotas(self): + main_quotas = QuotaAssociation.objects.current().filter( + sub_quota__order_number=self.quota, + ) + return main_quotas + @cached_property def quota_data(self): if not self.kwargs.get("quota_type"): @@ -332,6 +341,7 @@ def get_context_data(self, *args, **kwargs): blocking_periods=self.blocking_periods, suspension_periods=self.suspension_periods, sub_quotas=self.sub_quotas, + main_quotas=self.main_quotas, *args, **kwargs, )