Skip to content

Commit

Permalink
Merge branch 'master' into TP2000-1471--task-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpepper-trade committed Nov 15, 2024
2 parents d103846 + 1f8014e commit d0466d4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions common/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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


Expand Down
16 changes: 9 additions & 7 deletions quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja
Original file line number Diff line number Diff line change
@@ -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 %}
<a class="govuk-link govuk-!-font-weight-bold"
Expand Down Expand Up @@ -36,7 +44,6 @@
{"html": main_quota_link},
{"html": object.get_sub_quota_relation_type_display()},
{"text": object.coefficient},
{"text": actions_html }
]) or "" }}
{% endfor %}

Expand All @@ -51,12 +58,7 @@
{% endif %}
{{
govukTable({
"head": [
{"text": "Order number"},
{"text": "Relationship type"},
{"text": "Co-efficient"},
{"text": "Actions"}
],
"head": table_head,
"rows": table_rows
})
}}
Expand Down
11 changes: 3 additions & 8 deletions quotas/jinja2/quotas/tables/sub_quotas.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% set table_rows = [] %}
{% if sub_quotas %}
<h3 class="govuk-heading-m">Sub-quotas</h3>
<p class="govuk-body">The following sub-quota definitions exist for definition periods on Quota {{ quota.order_number}}.</p>
{% for object in sub_quotas %}
{% set definition_link -%}
<a class="govuk-link" href="{{ url('quota-ui-detail', args=[object.sub_quota.order_number.sid]) }}#definition-details">{{ object.sub_quota.sid }}</a>
Expand All @@ -11,7 +12,7 @@
<a class="govuk-link" href="{{ url('quota-ui-detail', args=[object.sub_quota.order_number.sid]) }}">{{ object.sub_quota.order_number.order_number }}</a>
{% endset %}
{% set actions_html %}
<a class="govuk-link" href="{{ object.sub_quota.version_at(request.user.current_workbasket.transactions.last()).get_association_edit_url() }}">Edit</a>
<a class="govuk-link" href="{{ object.sub_quota.get_association_edit_url() }}">Edit</a>
<br/>
<a class="govuk-link" href="{{ url('quota_association-ui-delete', args=[object.pk]) }}">Delete</a>
{% endset %}
Expand Down Expand Up @@ -41,26 +42,21 @@
}) }}
{% elif main_quotas %}
<h3 class="govuk-heading-m">Main quotas</h3>
<p class="govuk-body">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.</p>
{% for object in main_quotas %}
{% set definition_link -%}
<a class="govuk-link" href="{{ url('quota-ui-detail', args=[object.main_quota.order_number.sid]) }}#definition-details">{{ object.main_quota.sid }}</a>
{% endset %}
{% set main_quota_link -%}
<a class="govuk-link" href="{{ url('quota-ui-detail', args=[object.main_quota.order_number.sid]) }}">{{ object.main_quota.order_number.order_number }}</a>
{% endset %}
{% set actions_html %}
<a class="govuk-link" href="{{ object.sub_quota.version_at(request.user.current_workbasket.transactions.last()).get_association_edit_url() }}">Edit</a>
<br/>
<a class="govuk-link" href="{{ url('quota_association-ui-delete', args=[object.pk]) }}">Delete</a>
{% endset %}
{{ table_rows.append([
{"text": definition_link },
{"text": main_quota_link },
{"text": "{:%d %b %Y}".format(object.main_quota.version_at(request.user.current_workbasket.transactions.last()).valid_between.lower) },
{"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({
Expand All @@ -71,7 +67,6 @@
{"text": "End date"},
{"text": "Relationship type"},
{"text": "Coefficient"},
{"text": "Actions"},
],
"rows": table_rows
}) }}
Expand Down
3 changes: 3 additions & 0 deletions quotas/views/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit d0466d4

Please sign in to comment.