mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-13 01:33:21 +00:00
sas: add permanent notification for SAS moderation
Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
parent
469304585c
commit
f0c34fe70c
@ -725,6 +725,10 @@ class SithFile(models.Model):
|
|||||||
super(SithFile, self).save(*args, **kwargs)
|
super(SithFile, self).save(*args, **kwargs)
|
||||||
if copy_rights:
|
if copy_rights:
|
||||||
self.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):
|
def apply_rights_recursively(self, only_folders=False):
|
||||||
children = self.children.all()
|
children = self.children.all()
|
||||||
|
@ -26,6 +26,7 @@ from django.db import models
|
|||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
@ -162,6 +163,14 @@ class Album(SithFile):
|
|||||||
self.file.name = self.name + '/thumb.jpg'
|
self.file.name = self.name + '/thumb.jpg'
|
||||||
self.save()
|
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):
|
class PeoplePictureRelation(models.Model):
|
||||||
"""
|
"""
|
||||||
|
@ -556,7 +556,7 @@ SITH_NOTIFICATIONS = [
|
|||||||
('MAILING_MODERATION', _("A new mailing list needs to be moderated")),
|
('MAILING_MODERATION', _("A new mailing list needs to be moderated")),
|
||||||
('NEWS_MODERATION', _("There are %s fresh news to be moderated")),
|
('NEWS_MODERATION', _("There are %s fresh news to be moderated")),
|
||||||
('FILE_MODERATION', _("New files 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")),
|
('NEW_PICTURES', _("You've been identified on some pictures")),
|
||||||
('REFILLING', _("You just refilled of %s €")),
|
('REFILLING', _("You just refilled of %s €")),
|
||||||
('SELLING', _("You just bought %s")),
|
('SELLING', _("You just bought %s")),
|
||||||
@ -568,6 +568,7 @@ SITH_NOTIFICATIONS = [
|
|||||||
# The callback must take the notif object as first and single argument.
|
# The callback must take the notif object as first and single argument.
|
||||||
SITH_PERMANENT_NOTIFICATIONS = {
|
SITH_PERMANENT_NOTIFICATIONS = {
|
||||||
'NEWS_MODERATION': 'com.models.news_notification_callback',
|
'NEWS_MODERATION': 'com.models.news_notification_callback',
|
||||||
|
'SAS_MODERATION': 'sas.models.sas_notification_callback',
|
||||||
}
|
}
|
||||||
|
|
||||||
SITH_QUICK_NOTIF = {
|
SITH_QUICK_NOTIF = {
|
||||||
|
Loading…
Reference in New Issue
Block a user