21 lines
No EOL
789 B
Python
21 lines
No EOL
789 B
Python
from django.apps import AppConfig
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
class RisksConfig(AppConfig):
|
|
default_auto_field = "django.db.models.BigAutoField"
|
|
name = "risks"
|
|
verbose_name = _("Risk Management")
|
|
|
|
def ready(self):
|
|
import risks.signals
|
|
|
|
try:
|
|
from django.db.utils import OperationalError, ProgrammingError
|
|
from .models import NotificationRule, NotificationKind
|
|
NotificationRule.objects.count()
|
|
except (OperationalError, ProgrammingError):
|
|
return
|
|
existing = set(NotificationRule.objects.values_list("kind", flat=True))
|
|
for kind, _label in NotificationKind.choices:
|
|
if kind not in existing:
|
|
NotificationRule.objects.create(kind=kind) |