From b791796399e6491c63f2880289450337086fbdeb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Dec 2024 10:02:51 +0000 Subject: [PATCH 1/2] Bump jinja2 from 3.1.4 to 3.1.5 (#1369) Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.4 to 3.1.5. - [Release notes](https://github.com/pallets/jinja/releases) - [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst) - [Commits](https://github.com/pallets/jinja/compare/3.1.4...3.1.5) --- updated-dependencies: - dependency-name: jinja2 dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 5c3443a78..58bbd5a5f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -42,7 +42,7 @@ freezegun==1.1.0 gevent==23.9.1 govuk-tech-docs-sphinx-theme==1.0.0 gunicorn==22.0.0 -Jinja2==3.1.4 +Jinja2==3.1.5 lark==1.1.9 lxml==5.2.2 markdown==3.6 From 24585b7f60a3e3224268e2cfe05ccc6720dff729 Mon Sep 17 00:00:00 2001 From: Matthew McKenzie <97194636+mattjamc@users.noreply.github.com> Date: Thu, 26 Dec 2024 21:40:47 +0000 Subject: [PATCH 2/2] TP2000-1596 Quotas - small fixes (#1365) * Fix delete association cancel button * Include unapproved measures * As at today and beyond --- .../includes/quotas/tabs/sub_quotas.jinja | 2 +- quotas/jinja2/quota-associations/delete.jinja | 6 ----- quotas/models.py | 27 +++++++++++++++++++ quotas/views/base.py | 4 +-- 4 files changed, 30 insertions(+), 9 deletions(-) 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})