I think this supersedes #360
Would be better, and possibly easir, to add notifications to the new UI. Here some notes on what it will take.
Here's the existing UI in the Accounting app:
Pretty simple. But has a lot of machinery behind it in the Django templates, which makes it difficult to move to the Work app.
The model is also fairly simple. I think all the fields we need for the UI (and in the API) is user, notice_type, and send.
class NoticeSetting(models.Model):
"""
Indicates, for a given user, whether to send notifications
of a given type to a given medium.
"""
user = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name=_("user"))
notice_type = models.ForeignKey(NoticeType, verbose_name=_("notice type"))
medium = models.CharField(_("medium"), max_length=1, choices=NOTICE_MEDIA)
send = models.BooleanField(_("send"), default=False)
scoping_content_type = models.ForeignKey(ContentType, null=True, blank=True)
scoping_object_id = models.PositiveIntegerField(null=True, blank=True)
scoping = GenericForeignKey("scoping_content_type", "scoping_object_id")
@classmethod
def for_user(cls, user, notice_type, medium, scoping=None):
"""
Kept for backwards compatibilty but isn't used anywhere within this app
@@@ consider deprecating
"""
return notice_setting_for_user(user, notice_type, medium, scoping)
class Meta:
verbose_name = _("notice setting")
verbose_name_plural = _("notice settings")
unique_together = ("user", "notice_type", "medium", "scoping_content_type", "scoping_object_id")
I think this supersedes #360 Would be better, and possibly easir, to add notifications to the new UI. Here some notes on what it will take.
Here's the existing UI in the Accounting app: Pretty simple. But has a lot of machinery behind it in the Django templates, which makes it difficult to move to the Work app.
The model is also fairly simple. I think all the fields we need for the UI (and in the API) is user, notice_type, and send.
This is the app: https://github.com/pinax/pinax-notifications We're on version 4.0.0.
By the way, notice settings are broken in testocp. They work in production ocp.