Commit f0c34fe7 authored by Skia's avatar Skia

sas: add permanent notification for SAS moderation

Signed-off-by: Skia's avatarSkia <skia@libskia.so>
parent 46930458
Pipeline #1283 passed with stage
in 5 minutes and 9 seconds
......@@ -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()
......
......@@ -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):
"""
......
......@@ -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 = {
......
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