diff --git a/core/models.py b/core/models.py index 45b8f78f..8573fd4a 100644 --- a/core/models.py +++ b/core/models.py @@ -725,6 +725,10 @@ class SithFile(models.Model): super(SithFile, self).save(*args, **kwargs) if copy_rights: self.copy_rights() + if self.is_in_sas: + for u in RealGroup.objects.filter(id=settings.SITH_GROUP_SAS_ADMIN_ID).first().users.all(): + Notification(user=u, url=reverse("sas:moderation"), + type="SAS_MODERATION", param="1").save() def apply_rights_recursively(self, only_folders=False): children = self.children.all() diff --git a/sas/models.py b/sas/models.py index 33ef8899..583c3f59 100644 --- a/sas/models.py +++ b/sas/models.py @@ -26,6 +26,7 @@ from django.db import models from django.core.urlresolvers import reverse from django.conf import settings from django.utils.translation import ugettext_lazy as _ +from django.utils import timezone from PIL import Image from io import BytesIO @@ -162,6 +163,14 @@ class Album(SithFile): self.file.name = self.name + '/thumb.jpg' self.save() +def sas_notification_callback(notif): + count = Picture.objects.filter(is_moderated=False).count() + if count: + notif.viewed = False + notif.param = "%s" % count + notif.date = timezone.now() + else: + notif.viewed = True class PeoplePictureRelation(models.Model): """ diff --git a/sith/settings.py b/sith/settings.py index d5ce3c17..779eb04e 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -556,7 +556,7 @@ SITH_NOTIFICATIONS = [ ('MAILING_MODERATION', _("A new mailing list needs to be moderated")), ('NEWS_MODERATION', _("There are %s fresh news to be moderated")), ('FILE_MODERATION', _("New files to be moderated")), - ('SAS_MODERATION', _("New pictures/album to be moderated in the SAS")), + ('SAS_MODERATION', _("There are %s pictures to be moderated in the SAS")), ('NEW_PICTURES', _("You've been identified on some pictures")), ('REFILLING', _("You just refilled of %s €")), ('SELLING', _("You just bought %s")), @@ -568,6 +568,7 @@ SITH_NOTIFICATIONS = [ # The callback must take the notif object as first and single argument. SITH_PERMANENT_NOTIFICATIONS = { 'NEWS_MODERATION': 'com.models.news_notification_callback', + 'SAS_MODERATION': 'sas.models.sas_notification_callback', } SITH_QUICK_NOTIF = {