Project-level quota exceeded: show a message

This commit is contained in:
Klaas van Schelven
2026-01-07 14:34:02 +01:00
parent 7b7cd66dfb
commit cdb9ef7fa7
3 changed files with 31 additions and 0 deletions

View File

@@ -9,6 +9,15 @@
{% block title %}{{ issue.title }} · {{ block.super }}{% endblock %}
{% block content %}
{% for warning in issue.project.get_warnings %}
<div class="flex p-4 bg-yellow-100 dark:bg-amber-800 border-b-2 border-yellow-200 dark:border-amber-900">
<div class="text-slate-800 dark:text-slate-100">
{{ warning }}
</div>
</div>
{% endfor %}
<div class="m-4 flex flex-col lg:flex-row-reverse"><!-- container for the white bit (issue title, buttons) at the top of the page -->
<div class="ml-auto flex-none pb-4 lg:pb-0"><!-- top, RHS (buttons) -->

View File

@@ -26,10 +26,18 @@
</div>
</div>
{% for warning in project.get_warnings %}
<div class="flex p-4 bg-yellow-100 dark:bg-amber-800 border-b-2 border-yellow-200 dark:border-amber-900">
<div class="text-slate-800 dark:text-slate-100">
{{ warning }}
</div>
</div>
{% endfor %}
<div class="m-4">
<h1 class="text-4xl mt-4 font-bold">{{ project.name }} - {% translate "Issues" %}</h1>
{% if unapplied_issue_ids %}
<div class="bg-red-100 w-full mt-2 mb-2 p-4 border-red-800 border-2">
{% 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." %}

View File

@@ -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"]),