Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add notifications to new UI #432

Open
bhaugen opened this issue Feb 22, 2018 · 1 comment
Open

add notifications to new UI #432

bhaugen opened this issue Feb 22, 2018 · 1 comment
Assignees
Labels
enhancement OCW Open Coop Work of FairCoop priority

Comments

@bhaugen
Copy link

bhaugen commented Feb 22, 2018

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:
screenshot from 2018-02-22 08-42-38
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")

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.

@bhaugen bhaugen added enhancement priority OCW Open Coop Work of FairCoop labels Feb 22, 2018
@bhaugen
Copy link
Author

bhaugen commented Feb 22, 2018

Here's the view: https://github.com/pinax/pinax-notifications/blob/master/pinax/notifications/views.py

Might be a little confusing. Ask me for help in deciphering.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement OCW Open Coop Work of FairCoop priority
Projects
None yet
Development

No branches or pull requests

2 participants