From d92a706920876aa0626aa5e4086b976c654ffd6d Mon Sep 17 00:00:00 2001 From: Skia Date: Sat, 10 Dec 2016 00:06:17 +0100 Subject: [PATCH] Refactor notifications --- core/migrations/0013_auto_20161209_2338.py | 33 ++++ core/models.py | 9 +- core/static/core/style.css | 6 + core/templates/core/base.jinja | 9 +- core/templates/core/notification_list.jinja | 24 +++ core/urls.py | 1 + core/views/files.py | 3 +- core/views/site.py | 11 +- counter/models.py | 11 +- locale/fr/LC_MESSAGES/django.po | 193 +++++++++++--------- sas/templates/sas/picture.jinja | 2 +- sas/views.py | 6 +- sith/settings.py | 9 +- 13 files changed, 203 insertions(+), 114 deletions(-) create mode 100644 core/migrations/0013_auto_20161209_2338.py create mode 100644 core/templates/core/notification_list.jinja diff --git a/core/migrations/0013_auto_20161209_2338.py b/core/migrations/0013_auto_20161209_2338.py new file mode 100644 index 00000000..15343814 --- /dev/null +++ b/core/migrations/0013_auto_20161209_2338.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0012_notification'), + ] + + operations = [ + migrations.RemoveField( + model_name='notification', + name='text', + ), + migrations.AddField( + model_name='notification', + name='param', + field=models.CharField(verbose_name='param', default='', max_length=128), + ), + migrations.AddField( + model_name='notification', + name='viewed', + field=models.BooleanField(verbose_name='viewed', default=False), + ), + migrations.AlterField( + model_name='notification', + name='type', + field=models.CharField(verbose_name='type', default='GENERIC', choices=[('FILE_MODERATION', 'New files to be moderated'), ('SAS_MODERATION', 'New pictures/album to be moderated in the SAS'), ('NEW_PICTURES', "You've been identified on some pictures"), ('REFILLING', 'You just refilled of %(amount)s €'), ('SELLING', 'You just bought %(selling)s'), ('GENERIC', 'You have a notification')], max_length=32), + ), + ] diff --git a/core/models.py b/core/models.py index 332dda63..59ea512f 100644 --- a/core/models.py +++ b/core/models.py @@ -853,8 +853,13 @@ class PageRev(models.Model): class Notification(models.Model): user = models.ForeignKey(User, related_name='notifications') url = models.CharField(_("url"), max_length=255) - text = models.CharField(_("text"), max_length=512) - type = models.CharField(_("text"), max_length=16, choices=settings.SITH_NOTIFICATIONS, blank=True, null=True) + param = models.CharField(_("param"), max_length=128, default="") + type = models.CharField(_("type"), max_length=32, choices=settings.SITH_NOTIFICATIONS, default="GENERIC") date = models.DateTimeField(_('date'), default=timezone.now) + viewed = models.BooleanField(_('viewed'), default=False) + def __str__(self): + if self.param: + return self.get_type_display() % self.param + return self.get_type_display() diff --git a/core/static/core/style.css b/core/static/core/style.css index 1dd0c8bc..776a0290 100644 --- a/core/static/core/style.css +++ b/core/static/core/style.css @@ -67,6 +67,7 @@ header form { display: none; position: fixed; background: lightgrey; + text-align: center; } #notif li:hover { background: #bcc; @@ -289,6 +290,11 @@ tbody>tr:hover { margin: 2px auto; display: block; } +#notifications li { + padding: 5px; + margin: 2px; + list-style: none; +} #moderation div { margin: 2px; padding: 2px; diff --git a/core/templates/core/base.jinja b/core/templates/core/base.jinja index da1d8d87..fcc2907f 100644 --- a/core/templates/core/base.jinja +++ b/core/templates/core/base.jinja @@ -39,17 +39,16 @@ {% endfor %} {{ user.get_display_name() }} - {% if user.notifications.exists() %} - 🔔 ({{ user.notifications.count() }}) + 🔔 ({{ user.notifications.filter(viewed=False).count() }}) - {% endif %} {% trans %}Tools{% endtrans %} {% trans %}Logout{% endtrans %}
diff --git a/core/templates/core/notification_list.jinja b/core/templates/core/notification_list.jinja new file mode 100644 index 00000000..7de1836b --- /dev/null +++ b/core/templates/core/notification_list.jinja @@ -0,0 +1,24 @@ +{% extends "core/base.jinja" %} + +{% block title %} +{% trans %}Notification list{% endtrans %} +{% endblock %} + +{% block content %} +

{% trans %}Notification list{% endtrans %}

+ +{% endblock %} + diff --git a/core/urls.py b/core/urls.py index 087d0c39..6a8ae9c7 100644 --- a/core/urls.py +++ b/core/urls.py @@ -4,6 +4,7 @@ from core.views import * urlpatterns = [ url(r'^$', index, name='index'), + url(r'^notifications$', NotificationList.as_view(), name='notification_list'), url(r'^notification/(?P[0-9]+)$', notification, name='notification'), # Search diff --git a/core/views/files.py b/core/views/files.py index 87d53671..ba10fd94 100644 --- a/core/views/files.py +++ b/core/views/files.py @@ -71,8 +71,7 @@ class AddFilesForm(forms.Form): if notif: for u in RealGroup.objects.filter(id=settings.SITH_SAS_ADMIN_GROUP_ID).first().users.all(): if not u.notifications.filter(type="FILE_MODERATION").exists(): - Notification(user=u, text=_("New files to be moderated"), - url=reverse("core:file_moderation"), type="FILE_MODERATION").save() + Notification(user=u, url=reverse("core:file_moderation"), type="FILE_MODERATION").save() class FileListView(ListView): diff --git a/core/views/site.py b/core/views/site.py index 1ba316aa..b8d013e3 100644 --- a/core/views/site.py +++ b/core/views/site.py @@ -4,6 +4,7 @@ from django.http import JsonResponse from django.core import serializers from django.db.models import Q from django.contrib.auth.decorators import login_required +from django.views.generic import ListView import os import json @@ -15,10 +16,18 @@ from club.models import Club def index(request, context=None): return render(request, "core/index.jinja") +class NotificationList(ListView): + model = Notification + template_name = "core/notification_list.jinja" + + def get_queryset(self): + return self.request.user.notifications.order_by('-id')[:20] + def notification(request, notif_id): notif = Notification.objects.filter(id=notif_id).first() if notif: - notif.delete() + notif.viewed = True + notif.save() return redirect(notif.url) return redirect("/") diff --git a/counter/models.py b/counter/models.py index c1a30fa4..da89f95b 100644 --- a/counter/models.py +++ b/counter/models.py @@ -270,11 +270,10 @@ class Refilling(models.Model): self.customer.amount += self.amount self.customer.save() self.is_validated = True - Notification( - user=self.customer.user, - url=reverse('core:user_account_detail', + Notification(user=self.customer.user, url=reverse('core:user_account_detail', kwargs={'user_id': self.customer.user.id, 'year': self.date.year, 'month': self.date.month}), - text=_("You just refilled of %(amount)s €") % {'amount': self.amount} + param=str(self.amount), + type="REFILLING", ).save() super(Refilling, self).save(*args, **kwargs) @@ -387,9 +386,9 @@ class Selling(models.Model): user=self.customer.user, url=reverse('core:user_account_detail', kwargs={'user_id': self.customer.user.id, 'year': self.date.year, 'month': self.date.month}), - text=_("You just bought %(quantity)d %(product_name)s") % {'quantity': self.quantity, 'product_name': self.label} + param="%d x %s" % (self.quantity, self.label), + type="SELLING", ).save() - super(Selling, self).save(*args, **kwargs) class Permanency(models.Model): diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 9b391a8b..cf21d0d5 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2016-12-09 18:03+0100\n" +"POT-Creation-Date: 2016-12-09 23:50+0100\n" "PO-Revision-Date: 2016-07-18\n" "Last-Translator: Skia \n" "Language-Team: AE info \n" @@ -85,12 +85,12 @@ msgstr "Compte club" msgid "%(club_account)s on %(bank_account)s" msgstr "%(club_account)s sur %(bank_account)s" -#: accounting/models.py:142 club/models.py:147 counter/models.py:401 +#: accounting/models.py:142 club/models.py:147 counter/models.py:400 #: launderette/models.py:122 msgid "start date" msgstr "date de début" -#: accounting/models.py:143 club/models.py:148 counter/models.py:402 +#: accounting/models.py:143 club/models.py:148 counter/models.py:401 msgid "end date" msgstr "date de fin" @@ -124,16 +124,16 @@ msgid "journal" msgstr "classeur" #: accounting/models.py:194 core/models.py:515 core/models.py:818 -#: core/models.py:858 counter/models.py:244 counter/models.py:293 -#: counter/models.py:418 eboutic/models.py:15 eboutic/models.py:48 +#: core/models.py:858 counter/models.py:244 counter/models.py:292 +#: counter/models.py:417 eboutic/models.py:15 eboutic/models.py:48 msgid "date" msgstr "date" -#: accounting/models.py:195 counter/models.py:419 +#: accounting/models.py:195 counter/models.py:418 msgid "comment" msgstr "commentaire" -#: accounting/models.py:196 counter/models.py:245 counter/models.py:294 +#: accounting/models.py:196 counter/models.py:245 counter/models.py:293 #: subscription/models.py:57 msgid "payment method" msgstr "méthode de paiement" @@ -159,7 +159,7 @@ msgid "accounting type" msgstr "type comptable" #: accounting/models.py:205 accounting/models.py:299 accounting/models.py:325 -#: accounting/models.py:348 counter/models.py:285 +#: accounting/models.py:348 counter/models.py:284 msgid "label" msgstr "intitulé" @@ -313,7 +313,7 @@ msgstr "Compte en banque : " #: counter/templates/counter/last_ops.jinja:59 #: launderette/templates/launderette/launderette_admin.jinja:16 #: launderette/views.py:146 sas/templates/sas/moderation.jinja:36 -#: sas/templates/sas/picture.jinja:66 +#: sas/templates/sas/picture.jinja:66 sas/templates/sas/picture.jinja:109 msgid "Delete" msgstr "Supprimer" @@ -652,9 +652,9 @@ msgstr "Vous ne pouvez pas faire de boucles dans les clubs" msgid "A club with that unix_name already exists" msgstr "Un club avec ce nom UNIX existe déjà." -#: club/models.py:145 counter/models.py:399 counter/models.py:416 +#: club/models.py:145 counter/models.py:398 counter/models.py:415 #: eboutic/models.py:14 eboutic/models.py:47 launderette/models.py:89 -#: launderette/models.py:126 sas/models.py:101 +#: launderette/models.py:126 sas/models.py:108 msgid "user" msgstr "nom d'utilisateur" @@ -843,7 +843,7 @@ msgstr "Membres" msgid "Old members" msgstr "Anciens membres" -#: club/views.py:49 core/templates/core/base.jinja:53 core/views/user.py:146 +#: club/views.py:49 core/templates/core/base.jinja:54 core/views/user.py:146 #: sas/templates/sas/picture.jinja:83 msgid "Tools" msgstr "Outils" @@ -858,7 +858,7 @@ msgstr "Propriétés" msgid "Select user" msgstr "Choisir un utilisateur" -#: club/views.py:150 sas/views.py:80 sas/views.py:131 sas/views.py:173 +#: club/views.py:150 sas/views.py:79 sas/views.py:129 sas/views.py:171 msgid "You do not have the permission to do that" msgstr "Vous n'avez pas la permission de faire cela" @@ -1299,9 +1299,18 @@ msgstr "contenu de la page" msgid "url" msgstr "url" -#: core/models.py:856 core/models.py:857 -msgid "text" -msgstr "texte" +#: core/models.py:856 +msgid "param" +msgstr "" + +#: core/models.py:857 launderette/models.py:62 launderette/models.py:87 +#: launderette/models.py:123 +msgid "type" +msgstr "type" + +#: core/models.py:859 +msgid "viewed" +msgstr "vue" #: core/templates/core/403.jinja:5 msgid "403, Forbidden" @@ -1328,74 +1337,78 @@ msgstr "Connexion" msgid "Register" msgstr "S'enregister" -#: core/templates/core/base.jinja:54 +#: core/templates/core/base.jinja:51 +msgid "View more" +msgstr "Voir plus" + +#: core/templates/core/base.jinja:55 msgid "Logout" msgstr "Déconnexion" -#: core/templates/core/base.jinja:56 core/templates/core/base.jinja.py:57 +#: core/templates/core/base.jinja:57 core/templates/core/base.jinja.py:58 msgid "Search" msgstr "Recherche" -#: core/templates/core/base.jinja:79 +#: core/templates/core/base.jinja:80 msgid "Main" msgstr "Accueil" -#: core/templates/core/base.jinja:80 +#: core/templates/core/base.jinja:81 msgid "Matmatronch" msgstr "Matmatronch" -#: core/templates/core/base.jinja:81 +#: core/templates/core/base.jinja:82 msgid "Wiki" msgstr "Wiki" -#: core/templates/core/base.jinja:82 sas/templates/sas/album.jinja:4 +#: core/templates/core/base.jinja:83 sas/templates/sas/album.jinja:4 #: sas/templates/sas/main.jinja:4 sas/templates/sas/main.jinja.py:8 #: sas/templates/sas/picture.jinja:26 msgid "SAS" msgstr "SAS" -#: core/templates/core/base.jinja:83 +#: core/templates/core/base.jinja:84 msgid "Forum" msgstr "Forum" -#: core/templates/core/base.jinja:84 +#: core/templates/core/base.jinja:85 msgid "Services" msgstr "Services" -#: core/templates/core/base.jinja:85 core/templates/core/file.jinja:20 +#: core/templates/core/base.jinja:86 core/templates/core/file.jinja:20 #: core/views/files.py:48 msgid "Files" msgstr "Fichiers" -#: core/templates/core/base.jinja:86 +#: core/templates/core/base.jinja:87 msgid "Sponsors" msgstr "Partenaires" -#: core/templates/core/base.jinja:87 +#: core/templates/core/base.jinja:88 msgid "Help" msgstr "Aide" -#: core/templates/core/base.jinja:120 +#: core/templates/core/base.jinja:121 msgid "Contacts" msgstr "Contacts" -#: core/templates/core/base.jinja:121 +#: core/templates/core/base.jinja:122 msgid "Legal notices" msgstr "Mentions légales" -#: core/templates/core/base.jinja:122 +#: core/templates/core/base.jinja:123 msgid "Intellectual property" msgstr "Propriété intellectuelle" -#: core/templates/core/base.jinja:123 +#: core/templates/core/base.jinja:124 msgid "Help & Documentation" msgstr "Aide & Documentation" -#: core/templates/core/base.jinja:124 +#: core/templates/core/base.jinja:125 msgid "R&D" msgstr "R&D" -#: core/templates/core/base.jinja:126 +#: core/templates/core/base.jinja:127 msgid "Site made by good people" msgstr "Site réalisé par des gens bons" @@ -1489,7 +1502,7 @@ msgstr "Télécharger" #: core/templates/core/file_detail.jinja:46 #: core/templates/core/file_moderation.jinja:23 -#: sas/templates/sas/moderation.jinja:32 +#: sas/templates/sas/moderation.jinja:32 sas/templates/sas/picture.jinja:107 msgid "Moderate" msgstr "Modérer" @@ -1498,7 +1511,7 @@ msgid "There is no file in this website." msgstr "Il n'y a pas de fichier sur ce site web." #: core/templates/core/file_moderation.jinja:4 -#: core/templates/core/file_moderation.jinja:8 sith/settings.py:456 +#: core/templates/core/file_moderation.jinja:8 msgid "File moderation" msgstr "Modération des fichiers" @@ -1633,6 +1646,11 @@ msgstr "L'équipe AE" msgid "New subscription to the UTBM student association" msgstr "Nouvelle cotisation à l'Association des Étudiants de l'UTBM" +#: core/templates/core/notification_list.jinja:4 +#: core/templates/core/notification_list.jinja:8 +msgid "Notification list" +msgstr "Liste des notifications" + #: core/templates/core/page.jinja:7 core/templates/core/page_list.jinja:4 #: core/templates/core/page_list.jinja:9 msgid "Page list" @@ -2076,10 +2094,6 @@ msgstr "Erreur de création du dossier %(folder_name)s : %(msg)s" msgid "Error uploading file %(file_name)s: %(msg)s" msgstr "Erreur d'envoi du fichier %(file_name)s : %(msg)s" -#: core/views/files.py:74 -msgid "New files to be moderated" -msgstr "Nouveaux fichiers à modérer" - #: core/views/forms.py:59 core/views/forms.py:62 msgid "Choose file" msgstr "Choisir un fichier" @@ -2185,7 +2199,7 @@ msgstr "groupe d'achat" msgid "archived" msgstr "archivé" -#: counter/models.py:114 counter/models.py:499 +#: counter/models.py:114 counter/models.py:498 msgid "product" msgstr "produit" @@ -2222,7 +2236,7 @@ msgstr "vendeurs" msgid "token" msgstr "jeton" -#: counter/models.py:143 counter/models.py:400 counter/models.py:417 +#: counter/models.py:143 counter/models.py:399 counter/models.py:416 #: launderette/models.py:16 msgid "counter" msgstr "comptoir" @@ -2231,7 +2245,7 @@ msgstr "comptoir" msgid "bank" msgstr "banque" -#: counter/models.py:249 counter/models.py:296 +#: counter/models.py:249 counter/models.py:295 msgid "is validated" msgstr "est validé" @@ -2239,42 +2253,37 @@ msgstr "est validé" msgid "refilling" msgstr "rechargement" -#: counter/models.py:277 -#, python-format -msgid "You just refilled of %(amount)s €" -msgstr "Vous avez rechargé de votre compte de %(amount)s €" - -#: counter/models.py:289 eboutic/models.py:103 +#: counter/models.py:288 eboutic/models.py:103 msgid "unit price" msgstr "prix unitaire" -#: counter/models.py:290 counter/models.py:489 eboutic/models.py:104 +#: counter/models.py:289 counter/models.py:488 eboutic/models.py:104 msgid "quantity" msgstr "quantité" -#: counter/models.py:295 +#: counter/models.py:294 msgid "Sith account" msgstr "Compte utilisateur" -#: counter/models.py:295 sith/settings.py:298 sith/settings.py:303 +#: counter/models.py:294 sith/settings.py:298 sith/settings.py:303 #: sith/settings.py:325 msgid "Credit card" msgstr "Carte bancaire" -#: counter/models.py:299 +#: counter/models.py:298 msgid "selling" msgstr "vente" -#: counter/models.py:318 +#: counter/models.py:317 msgid "Unknown event" msgstr "Événement inconnu" -#: counter/models.py:319 +#: counter/models.py:318 #, python-format msgid "Eticket bought for the event %(event)s" msgstr "Eticket acheté pour l'événement %(event)s" -#: counter/models.py:321 counter/models.py:333 +#: counter/models.py:320 counter/models.py:332 #, python-format msgid "" "You bought an eticket for the event %(event)s.\n" @@ -2283,56 +2292,51 @@ msgstr "" "Vous avez acheté un Eticket pour l'événement %(event)s.\n" "Vous pouvez le télécharger sur cette page: %(url)s" -#: counter/models.py:390 -#, python-format -msgid "You just bought %(quantity)d %(product_name)s" -msgstr "Vous avez acheté %(quantity)d %(product_name)s" - -#: counter/models.py:403 +#: counter/models.py:402 msgid "last activity date" msgstr "dernière activité" -#: counter/models.py:406 +#: counter/models.py:405 msgid "permanency" msgstr "permanence" -#: counter/models.py:420 +#: counter/models.py:419 msgid "emptied" msgstr "coffre vidée" -#: counter/models.py:423 +#: counter/models.py:422 msgid "cash register summary" msgstr "relevé de caisse" -#: counter/models.py:487 +#: counter/models.py:486 msgid "cash summary" msgstr "relevé" -#: counter/models.py:488 +#: counter/models.py:487 msgid "value" msgstr "valeur" -#: counter/models.py:490 +#: counter/models.py:489 msgid "check" msgstr "chèque" -#: counter/models.py:493 +#: counter/models.py:492 msgid "cash register summary item" msgstr "élément de relevé de caisse" -#: counter/models.py:500 +#: counter/models.py:499 msgid "banner" msgstr "bannière" -#: counter/models.py:501 +#: counter/models.py:500 msgid "event date" msgstr "date de l'événement" -#: counter/models.py:502 +#: counter/models.py:501 msgid "event title" msgstr "titre de l'événement" -#: counter/models.py:503 +#: counter/models.py:502 msgid "secret" msgstr "secret" @@ -2410,7 +2414,7 @@ msgstr "Non autorisé pour ce produit" #: counter/templates/counter/counter_click.jinja:45 #: counter/templates/counter/counter_click.jinja:79 msgid "No date of birth provided" -msgstr "Pas de date de naissance renseigné" +msgstr "Pas de date de naissance renseignée" #: counter/templates/counter/counter_click.jinja:55 #: counter/templates/counter/counter_click.jinja:103 @@ -2764,10 +2768,6 @@ msgstr "Laverie" msgid "launderette" msgstr "laverie" -#: launderette/models.py:62 launderette/models.py:87 launderette/models.py:123 -msgid "type" -msgstr "type" - #: launderette/models.py:63 msgid "is working" msgstr "fonctionne" @@ -2894,7 +2894,7 @@ msgstr "Utilisateur qui sera conservé" msgid "User that will be deleted" msgstr "Utilisateur qui sera supprimé" -#: sas/models.py:102 +#: sas/models.py:109 msgid "picture" msgstr "photo" @@ -2913,7 +2913,6 @@ msgid "Create" msgstr "Créer" #: sas/templates/sas/moderation.jinja:4 sas/templates/sas/moderation.jinja:8 -#: sith/settings.py:457 msgid "SAS moderation" msgstr "Modération du SAS" @@ -2966,18 +2965,10 @@ msgstr "Envoyer les images" msgid "Error creating album %(album)s: %(msg)s" msgstr "Erreur de création de l'album %(album)s : %(msg)s" -#: sas/views.py:54 -msgid "New pictures/album to be moderated in the SAS" -msgstr "Nouvelles photos/albums à modérer dans le SAS" - -#: sas/views.py:62 +#: sas/views.py:61 msgid "Add user" msgstr "Ajouter une personne" -#: sas/views.py:127 -msgid "You've been identified on some pictures" -msgstr "Vous avez été identifié sur des photos" - #: sith/settings.py:166 msgid "English" msgstr "Anglais" @@ -3090,9 +3081,31 @@ msgstr "Membre actif" msgid "Curious" msgstr "Curieux" +#: sith/settings.py:456 +msgid "New files to be moderated" +msgstr "Nouveaux fichiers à modérer" + +#: sith/settings.py:457 +msgid "New pictures/album to be moderated in the SAS" +msgstr "Nouvelles photos/albums à modérer dans le SAS" + #: sith/settings.py:458 -msgid "New pictures" -msgstr "Nouvelle photo" +msgid "You've been identified on some pictures" +msgstr "Vous avez été identifié sur des photos" + +#: sith/settings.py:459 +#, python-format +msgid "You just refilled of %s €" +msgstr "Vous avez rechargé votre compte de %s €" + +#: sith/settings.py:460 +#, python-format +msgid "You just bought %s" +msgstr "Vous avez acheté %s" + +#: sith/settings.py:461 +msgid "You have a notification" +msgstr "Vous avez une notification" #: subscription/models.py:16 msgid "Bad subscription type" diff --git a/sas/templates/sas/picture.jinja b/sas/templates/sas/picture.jinja index 3cef6a53..bfeedae4 100644 --- a/sas/templates/sas/picture.jinja +++ b/sas/templates/sas/picture.jinja @@ -95,7 +95,7 @@ {% if picture.is_moderated %}
{% else %} -
+
{% set next = picture.get_next() %} {% if not next %} {% set next = url('sas:moderation') %} diff --git a/sas/views.py b/sas/views.py index 33045b64..4ccc752d 100644 --- a/sas/views.py +++ b/sas/views.py @@ -51,8 +51,7 @@ class SASForm(forms.Form): if notif: for u in RealGroup.objects.filter(id=settings.SITH_SAS_ADMIN_GROUP_ID).first().users.all(): if not u.notifications.filter(type="SAS_MODERATION").exists(): - Notification(user=u, text=_("New pictures/album to be moderated in the SAS"), - url=reverse("sas:moderation"), type="SAS_MODERATION").save() + Notification(user=u, url=reverse("sas:moderation"), type="SAS_MODERATION").save() class RelationForm(forms.ModelForm): class Meta: @@ -124,8 +123,7 @@ class PictureView(CanViewMixin, DetailView, FormMixin): PeoplePictureRelation(user=u, picture=self.form.cleaned_data['picture']).save() if not u.notifications.filter(type="NEW_PICTURES").exists(): - Notification(user=u, text=_("You've been identified on some pictures"), - url=reverse("core:user_pictures", kwargs={'user_id': u.id}), type="NEW_PICTURES").save() + Notification(user=u, url=reverse("core:user_pictures", kwargs={'user_id': u.id}), type="NEW_PICTURES").save() return super(PictureView, self).form_valid(self.form) else: self.form.add_error(None, _("You do not have the permission to do that")) diff --git a/sith/settings.py b/sith/settings.py index 6046b689..324fee3b 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -453,9 +453,12 @@ SITH_SAS_ROOT_DIR_ID = 4 SITH_SAS_ADMIN_GROUP_ID = 9 SITH_NOTIFICATIONS = [ - ('FILE_MODERATION', _("File moderation")), - ('SAS_MODERATION', _("SAS moderation")), - ('NEW_PICTURES', _("New pictures")), + ('FILE_MODERATION', _("New files to be moderated")), + ('SAS_MODERATION', _("New pictures/album 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")), + ('GENERIC', _("You have a notification")), ] try: