Add notification with a fresh new

This commit is contained in:
Skia 2016-12-23 20:11:27 +01:00
parent be44a3ab0b
commit b79c77f268
3 changed files with 37 additions and 25 deletions

View File

@ -6,6 +6,7 @@ from django.utils.translation import ugettext_lazy as _
from django.core.urlresolvers import reverse, reverse_lazy from django.core.urlresolvers import reverse, reverse_lazy
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.utils import timezone from django.utils import timezone
from django.conf import settings
from django import forms from django import forms
from datetime import timedelta from datetime import timedelta
@ -13,6 +14,7 @@ from datetime import timedelta
from com.models import Sith, News, NewsDate from com.models import Sith, News, NewsDate
from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, CanCreateMixin from core.views import CanViewMixin, CanEditMixin, CanEditPropMixin, TabedViewMixin, CanCreateMixin
from core.views.forms import SelectDateTime from core.views.forms import SelectDateTime
from core.models import Notification, RealGroup
from club.models import Club from club.models import Club
@ -141,6 +143,9 @@ class NewsEditView(CanEditMixin, UpdateView):
else: else:
self.object.is_moderated = False self.object.is_moderated = False
self.object.save() self.object.save()
for u in RealGroup.objects.filter(id=settings.SITH_GROUP_COM_ADMIN_ID).first().users.all():
if not u.notifications.filter(type="NEWS_MODERATION", viewed=False).exists():
Notification(user=u, url=reverse("com:news_detail", kwargs={'news_id': self.object.id}), type="NEWS_MODERATION").save()
return super(NewsEditView, self).form_valid(form) return super(NewsEditView, self).form_valid(form)
class NewsCreateView(CanCreateMixin, CreateView): class NewsCreateView(CanCreateMixin, CreateView):
@ -165,12 +170,14 @@ class NewsCreateView(CanCreateMixin, CreateView):
def form_valid(self, form): def form_valid(self, form):
self.object = form.save() self.object = form.save()
print(form.cleaned_data)
if form.cleaned_data['automoderation'] and self.request.user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID): if form.cleaned_data['automoderation'] and self.request.user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID):
print("GUY")
self.object.moderator = self.request.user self.object.moderator = self.request.user
self.object.is_moderated = True self.object.is_moderated = True
self.object.save() self.object.save()
else:
for u in RealGroup.objects.filter(id=settings.SITH_GROUP_COM_ADMIN_ID).first().users.all():
if not u.notifications.filter(type="NEWS_MODERATION", viewed=False).exists():
Notification(user=u, url=reverse("com:news_detail", kwargs={'news_id': self.object.id}), type="NEWS_MODERATION").save()
return super(NewsCreateView, self).form_valid(form) return super(NewsCreateView, self).form_valid(form)
class NewsModerateView(CanEditMixin, SingleObjectMixin): class NewsModerateView(CanEditMixin, SingleObjectMixin):

View File

@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-12-23 19:35+0100\n" "POT-Creation-Date: 2016-12-23 20:10+0100\n"
"PO-Revision-Date: 2016-07-18\n" "PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Skia <skia@libskia.so>\n" "Last-Translator: Skia <skia@libskia.so>\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
@ -979,7 +979,7 @@ msgstr "Vous n'avez pas la permission de faire cela"
msgid "Begin date" msgid "Begin date"
msgstr "Date de début" msgstr "Date de début"
#: club/views.py:166 com/views.py:79 counter/views.py:909 #: club/views.py:166 com/views.py:81 counter/views.py:909
msgid "End date" msgid "End date"
msgstr "Date de fin" msgstr "Date de fin"
@ -1057,11 +1057,6 @@ msgstr "date de début"
msgid "end_date" msgid "end_date"
msgstr "date de fin" msgstr "date de fin"
#: com/templates/com/macros.jinja:26 com/templates/com/news_detail.jinja:22
#: com/templates/com/news_edit.jinja:34
msgid "Author: "
msgstr "Auteur : "
#: com/templates/com/news_admin_list.jinja:5 #: com/templates/com/news_admin_list.jinja:5
msgid "News admin" msgid "News admin"
msgstr "Administration des nouvelles" msgstr "Administration des nouvelles"
@ -1118,6 +1113,10 @@ msgstr "Modérer"
msgid "Back to news" msgid "Back to news"
msgstr "Retour aux nouvelles" msgstr "Retour aux nouvelles"
#: com/templates/com/news_detail.jinja:22 com/templates/com/news_edit.jinja:34
msgid "Author: "
msgstr "Auteur : "
#: com/templates/com/news_detail.jinja:24 sas/templates/sas/picture.jinja:82 #: com/templates/com/news_detail.jinja:24 sas/templates/sas/picture.jinja:82
msgid "Moderator: " msgid "Moderator: "
msgstr "Modérateur : " msgstr "Modérateur : "
@ -1147,14 +1146,15 @@ msgid ""
"Weekly: recurrent event, associated with many dates (specify the first one, " "Weekly: recurrent event, associated with many dates (specify the first one, "
"and a deadline)" "and a deadline)"
msgstr "" msgstr ""
"Hebdomadaire : événement récurrent, associé à plusieurs dates (spécifier la première, " "Hebdomadaire : événement récurrent, associé à plusieurs dates (spécifier la "
"ainsi que la date de fin)" "première, ainsi que la date de fin)"
#: com/templates/com/news_edit.jinja:51 #: com/templates/com/news_edit.jinja:51
msgid "" msgid ""
"Call: long time event, associated with a long date (election appliance, ...)" "Call: long time event, associated with a long date (election appliance, ...)"
msgstr "" msgstr ""
"Appel : événement de longue durée, associé à une longue date (candidature, concours, ...)" "Appel : événement de longue durée, associé à une longue date (candidature, "
"concours, ...)"
#: com/templates/com/news_edit.jinja:65 #: com/templates/com/news_edit.jinja:65
#: core/templates/core/pagerev_edit.jinja:23 #: core/templates/core/pagerev_edit.jinja:23
@ -1169,35 +1169,35 @@ msgstr "Événement aujourd'hui et dans les prochains jours"
msgid "Coming soon... don't miss!" msgid "Coming soon... don't miss!"
msgstr "Prochainement... à ne pas rater!" msgstr "Prochainement... à ne pas rater!"
#: com/views.py:25 #: com/views.py:27
msgid "Communication administration" msgid "Communication administration"
msgstr "Administration de la communication" msgstr "Administration de la communication"
#: com/views.py:32 #: com/views.py:34
msgid "Index page" msgid "Index page"
msgstr "Page d'accueil" msgstr "Page d'accueil"
#: com/views.py:37 #: com/views.py:39
msgid "Info message" msgid "Info message"
msgstr "Message d'info" msgstr "Message d'info"
#: com/views.py:42 #: com/views.py:44
msgid "Alert message" msgid "Alert message"
msgstr "Message d'alerte" msgstr "Message d'alerte"
#: com/views.py:78 #: com/views.py:80
msgid "Start date" msgid "Start date"
msgstr "Date de début" msgstr "Date de début"
#: com/views.py:80 #: com/views.py:82
msgid "Until" msgid "Until"
msgstr "Jusqu'à" msgstr "Jusqu'à"
#: com/views.py:81 #: com/views.py:83
msgid "Automoderation" msgid "Automoderation"
msgstr "Automodération" msgstr "Automodération"
#: com/views.py:87 com/views.py:89 com/views.py:91 #: com/views.py:89 com/views.py:91 com/views.py:93
msgid "This field is required." msgid "This field is required."
msgstr "Ce champ est obligatoire." msgstr "Ce champ est obligatoire."
@ -3407,28 +3407,32 @@ msgid "Curious"
msgstr "Curieux" msgstr "Curieux"
#: sith/settings.py:443 #: sith/settings.py:443
msgid "A fresh new to be moderated"
msgstr "Une nouvelle toute neuve à modérer"
#: sith/settings.py:444
msgid "New files to be moderated" msgid "New files to be moderated"
msgstr "Nouveaux fichiers à modérer" msgstr "Nouveaux fichiers à modérer"
#: sith/settings.py:444 #: sith/settings.py:445
msgid "New pictures/album to be moderated in the SAS" msgid "New pictures/album to be moderated in the SAS"
msgstr "Nouvelles photos/albums à modérer dans le SAS" msgstr "Nouvelles photos/albums à modérer dans le SAS"
#: sith/settings.py:445 #: sith/settings.py:446
msgid "You've been identified on some pictures" msgid "You've been identified on some pictures"
msgstr "Vous avez été identifié sur des photos" msgstr "Vous avez été identifié sur des photos"
#: sith/settings.py:446 #: sith/settings.py:447
#, python-format #, python-format
msgid "You just refilled of %s €" msgid "You just refilled of %s €"
msgstr "Vous avez rechargé votre compte de %s €" msgstr "Vous avez rechargé votre compte de %s €"
#: sith/settings.py:447 #: sith/settings.py:448
#, python-format #, python-format
msgid "You just bought %s" msgid "You just bought %s"
msgstr "Vous avez acheté %s" msgstr "Vous avez acheté %s"
#: sith/settings.py:448 #: sith/settings.py:449
msgid "You have a notification" msgid "You have a notification"
msgstr "Vous avez une notification" msgstr "Vous avez une notification"

View File

@ -440,6 +440,7 @@ SITH_LAUNDERETTE_PRICES = {
} }
SITH_NOTIFICATIONS = [ SITH_NOTIFICATIONS = [
('NEWS_MODERATION', _("A fresh new 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', _("New pictures/album to be moderated in the SAS")),
('NEW_PICTURES', _("You've been identified on some pictures")), ('NEW_PICTURES', _("You've been identified on some pictures")),