Quota warning message: formatting

This commit is contained in:
Klaas van Schelven
2026-01-07 14:51:08 +01:00
parent 1c0d163f92
commit 7bb6673e39

View File

@@ -7,6 +7,7 @@ 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 django.utils.timezone import localtime
from bugsink.app_settings import get_settings
from bugsink.transaction import delay_on_commit
@@ -179,8 +180,10 @@ class Project(models.Model):
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)]
per_fmt = "%s %ss" % (nr_of_periods, period_name) if nr_of_periods != 1 else period_name
date_fmt = date(localtime(self.quota_exceeded_until), "j M G:i T")
return ["Event ingestion stopped until %s. Reason: project quota (%s events per %s) exceeded." % (
date_fmt, gte_threshold, per_fmt)]
return []