sas: add permanent notification for SAS moderation

Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
Skia 2017-09-25 12:35:56 +02:00
parent 469304585c
commit f0c34fe70c
3 changed files with 15 additions and 1 deletions

View File

@ -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()

View File

@ -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):
"""

View File

@ -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 = {