from django.db import models from django.utils.translation import gettext_lazy as _ from .notification_kind import NotificationKind # --------------------------------------------------------------------------- # NotificationRule # --------------------------------------------------------------------------- class NotificationRule(models.Model): """Global rules: Which events trigger in-app and/or email notifications.""" class Meta: verbose_name = _("Notification rule") verbose_name_plural = _("Notification rules") kind = models.CharField( _("Event"), max_length=40, choices=NotificationKind.choices, unique=True, ) enabled_in_app = models.BooleanField(_("Show in app"), default=True) enabled_email = models.BooleanField(_("Send via email"), default=False) # Recipient groups to_owner = models.BooleanField( _("Send to owner/responsible/reporter (if available)"), default=True, ) to_staff = models.BooleanField(_("Send to all staff"), default=False) extra_recipients = models.TextField( _("Extra recipients (emails, comma or newline separated)"), blank=True, ) def __str__(self): return self.get_kind_display() or self.kind