Commit c1514ab7 by benjaoming

Do not delete old notifications when user unsubscribes + allow notifications to…

Do not delete old notifications when user unsubscribes + allow notifications to be created without a subscription (to enable notifications for only one specific user)
parent 4800d5b6
...@@ -6,7 +6,12 @@ from django.contrib.auth.decorators import login_required ...@@ -6,7 +6,12 @@ from django.contrib.auth.decorators import login_required
import django_notify import django_notify
def disable_notify(func): def disable_notify(func):
"""Disable notifications within a """ """Disable notifications. Example:
@disable_notify
def your_function():
notify("no one will be notified", ...)
"""
def wrap(request, *args, **kwargs): def wrap(request, *args, **kwargs):
django_notify._disable_notifications = True django_notify._disable_notifications = True
response = func(request, *args, **kwargs) response = func(request, *args, **kwargs)
......
...@@ -58,7 +58,7 @@ class Subscription(models.Model): ...@@ -58,7 +58,7 @@ class Subscription(models.Model):
class Notification(models.Model): class Notification(models.Model):
subscription = models.ForeignKey(Subscription) subscription = models.ForeignKey(Subscription, null=True, blank=True, on_delete=models.SET_NULL)
message = models.TextField() message = models.TextField()
url = models.URLField(blank=True, null=True, verbose_name=_(u'link for notification')) url = models.URLField(blank=True, null=True, verbose_name=_(u'link for notification'))
is_viewed = models.BooleanField(default=False) is_viewed = models.BooleanField(default=False)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment