From cdb9ef7fa7200cc7cf9d1cb78e7cdbb841b45131 Mon Sep 17 00:00:00 2001 From: Klaas van Schelven Date: Wed, 7 Jan 2026 14:34:02 +0100 Subject: [PATCH] Project-level quota exceeded: show a message --- issues/templates/issues/base.html | 9 +++++++++ issues/templates/issues/issue_list.html | 8 ++++++++ projects/models.py | 14 ++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/issues/templates/issues/base.html b/issues/templates/issues/base.html index 687d0f9..e772917 100644 --- a/issues/templates/issues/base.html +++ b/issues/templates/issues/base.html @@ -9,6 +9,15 @@ {% block title %}{{ issue.title }} ยท {{ block.super }}{% endblock %} {% block content %} + +{% for warning in issue.project.get_warnings %} +
+
+ {{ warning }} +
+
+{% endfor %} +
diff --git a/issues/templates/issues/issue_list.html b/issues/templates/issues/issue_list.html index c6418ed..004df5b 100644 --- a/issues/templates/issues/issue_list.html +++ b/issues/templates/issues/issue_list.html @@ -26,10 +26,18 @@
+{% for warning in project.get_warnings %} +
+
+ {{ warning }} +
+
+{% endfor %}

{{ project.name }} - {% translate "Issues" %}

+ {% if unapplied_issue_ids %}
{% translate "The chosen action is not applicable to all selected issues. Issues for which it has not been applied have been left with checkboxes checked so that you can try again with another action." %} diff --git a/projects/models.py b/projects/models.py index 28c3289..48f400a 100644 --- a/projects/models.py +++ b/projects/models.py @@ -1,9 +1,12 @@ import uuid +import json +from datetime import datetime, timezone from django.db import models from django.conf import settings from django.utils.text import slugify from django.utils.translation import gettext_lazy as _, pgettext_lazy +from django.template.defaultfilters import date from bugsink.app_settings import get_settings from bugsink.transaction import delay_on_commit @@ -170,6 +173,17 @@ class Project(models.Model): def is_discoverable(self): return self.visibility <= ProjectVisibility.DISCOVERABLE + def get_warnings(self): + now = datetime.now(timezone.utc) + from ingest.views import BaseIngestAPIView + if BaseIngestAPIView.is_quota_still_exceeded(self, now): + period_name, nr_of_periods, gte_threshold = json.loads(self.quota_exceeded_reason) + # TODO i18n + return ["Event ingestion stopped until %s. Reason: project quota (%s events per %s %ss) exceeded." % ( + date(self.quota_exceeded_until, "j M G:i"), gte_threshold, nr_of_periods, period_name)] + + return [] + class Meta: indexes = [ models.Index(fields=["name"]),