diff --git a/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja b/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja
index b126979b4..3972ddc5d 100644
--- a/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja
+++ b/quotas/jinja2/includes/quotas/tabs/sub_quotas.jinja
@@ -17,7 +17,7 @@
{% set actions_html %}
Edit
- Delete
+ Delete
{% endset %}
{{ table_rows.append([
{"html": sub_quota_link},
diff --git a/quotas/jinja2/quota-associations/delete.jinja b/quotas/jinja2/quota-associations/delete.jinja
index c6ef1e6c0..3df624e41 100644
--- a/quotas/jinja2/quota-associations/delete.jinja
+++ b/quotas/jinja2/quota-associations/delete.jinja
@@ -21,10 +21,4 @@
{% call django_form(action="") %}
{{ crispy(form) }}
{% endcall %}
-
- {{ govukButton({
- "text": "Cancel",
- "href": object.get_url(),
- "classes": "govuk-button--secondary"
- }) }}
{% endblock %}
diff --git a/quotas/models.py b/quotas/models.py
index 475e2100e..01627ed78 100644
--- a/quotas/models.py
+++ b/quotas/models.py
@@ -465,6 +465,33 @@ class QuotaAssociation(TrackedModel):
business_rules.SameMainAndSubQuota,
)
+ def get_url(self, action: str = "detail") -> Optional[str]:
+ """
+ Generate a URL to a representation of the model in the webapp.
+
+ Custom for quota associations as they do not have a detail view or
+ typical list/edit views.
+ """
+ if action == "edit":
+ url = self.sub_quota.get_association_edit_url()
+ return url
+ try:
+ if action == "create":
+ url = reverse("sub_quota_definitions-ui-create")
+ elif action == "delete":
+ url = reverse("quota_association-ui-delete", kwargs={"pk": self.pk})
+ else:
+ url = reverse(
+ "quota_definition-ui-list-filter",
+ kwargs={
+ "sid": self.main_quota.order_number.sid,
+ "quota_type": "quota_associations",
+ },
+ )
+ return url
+ except NoReverseMatch:
+ return None
+
class QuotaSuspension(TrackedModel, ValidityMixin):
"""Defines a suspension period for a quota."""
diff --git a/quotas/views/base.py b/quotas/views/base.py
index 59457b0ef..49519047b 100644
--- a/quotas/views/base.py
+++ b/quotas/views/base.py
@@ -239,9 +239,9 @@ def get_context_data(self, *args, **kwargs):
order = "goods_nomenclature"
context["measures"] = (
- Measure.objects.latest_approved()
+ Measure.objects.current()
.filter(order_number=self.object)
- .as_at(date.today())
+ .as_at_today_and_beyond()
.order_by(order)
)
url_params = urlencode({"order_number": self.object.pk})