Refactor notifications

This commit is contained in:
Skia 2016-12-10 00:06:17 +01:00
parent b53531c391
commit d92a706920
13 changed files with 203 additions and 114 deletions

View File

@ -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),
),
]

View File

@ -853,8 +853,13 @@ class PageRev(models.Model):
class Notification(models.Model): class Notification(models.Model):
user = models.ForeignKey(User, related_name='notifications') user = models.ForeignKey(User, related_name='notifications')
url = models.CharField(_("url"), max_length=255) url = models.CharField(_("url"), max_length=255)
text = models.CharField(_("text"), max_length=512) param = models.CharField(_("param"), max_length=128, default="")
type = models.CharField(_("text"), max_length=16, choices=settings.SITH_NOTIFICATIONS, blank=True, null=True) type = models.CharField(_("type"), max_length=32, choices=settings.SITH_NOTIFICATIONS, default="GENERIC")
date = models.DateTimeField(_('date'), default=timezone.now) 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()

View File

@ -67,6 +67,7 @@ header form {
display: none; display: none;
position: fixed; position: fixed;
background: lightgrey; background: lightgrey;
text-align: center;
} }
#notif li:hover { #notif li:hover {
background: #bcc; background: #bcc;
@ -289,6 +290,11 @@ tbody>tr:hover {
margin: 2px auto; margin: 2px auto;
display: block; display: block;
} }
#notifications li {
padding: 5px;
margin: 2px;
list-style: none;
}
#moderation div { #moderation div {
margin: 2px; margin: 2px;
padding: 2px; padding: 2px;

View File

@ -39,17 +39,16 @@
{% endfor %} {% endfor %}
</ul> </ul>
<a href="{{ url('core:user_profile', user_id=user.id) }}">{{ user.get_display_name() }}</a> <a href="{{ url('core:user_profile', user_id=user.id) }}">{{ user.get_display_name() }}</a>
{% if user.notifications.exists() %} <a href="#" onclick="display_notif()">&#x1f514; ({{ user.notifications.filter(viewed=False).count() }})</a>
<a href="#" onclick="display_notif()">&#x1f514; ({{ user.notifications.count() }})</a>
<ul id="notif"> <ul id="notif">
{% for n in user.notifications.order_by('-id') %} {% for n in user.notifications.filter(viewed=False).order_by('-id') %}
<li><a href="{{ url("core:notification", notif_id=n.id) }}"> <li><a href="{{ url("core:notification", notif_id=n.id) }}">
<span style="font-size: small; ">{{ n.date|date(DATE_FORMAT) }} {{ <span style="font-size: small; ">{{ n.date|date(DATE_FORMAT) }} {{
n.date|time(DATETIME_FORMAT) }}</span><br> n.date|time(DATETIME_FORMAT) }}</span><br>
{{ n.text }}</a></li> {{ n }}</a></li>
{% endfor %} {% endfor %}
<li><a href="{{ url('core:notification_list') }}">{% trans %}View more{% endtrans %}</a></li>
</ul> </ul>
{% endif %}
<a href="{{ url('core:user_tools') }}">{% trans %}Tools{% endtrans %}</a> <a href="{{ url('core:user_tools') }}">{% trans %}Tools{% endtrans %}</a>
<a href="{{ url('core:logout') }}">{% trans %}Logout{% endtrans %}</a> <a href="{{ url('core:logout') }}">{% trans %}Logout{% endtrans %}</a>
<form action="{{ url('core:search') }}" method="GET"> <form action="{{ url('core:search') }}" method="GET">

View File

@ -0,0 +1,24 @@
{% extends "core/base.jinja" %}
{% block title %}
{% trans %}Notification list{% endtrans %}
{% endblock %}
{% block content %}
<h3>{% trans %}Notification list{% endtrans %}</h3>
<ul id="notifications">
{% for n in notification_list %}
{% if n.viewed %}
<li>
{% else %}
<li style="background: lightgrey;">
{% endif %}
<a href="{{ url("core:notification", notif_id=n.id) }}">
<span style="font-size: small; ">{{ n.date|date(DATE_FORMAT) }} {{
n.date|time(DATETIME_FORMAT) }}</span><br>
{{ n }}</a>
</li>
{% endfor %}
</ul>
{% endblock %}

View File

@ -4,6 +4,7 @@ from core.views import *
urlpatterns = [ urlpatterns = [
url(r'^$', index, name='index'), url(r'^$', index, name='index'),
url(r'^notifications$', NotificationList.as_view(), name='notification_list'),
url(r'^notification/(?P<notif_id>[0-9]+)$', notification, name='notification'), url(r'^notification/(?P<notif_id>[0-9]+)$', notification, name='notification'),
# Search # Search

View File

@ -71,8 +71,7 @@ class AddFilesForm(forms.Form):
if notif: if notif:
for u in RealGroup.objects.filter(id=settings.SITH_SAS_ADMIN_GROUP_ID).first().users.all(): 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(): if not u.notifications.filter(type="FILE_MODERATION").exists():
Notification(user=u, text=_("New files to be moderated"), Notification(user=u, url=reverse("core:file_moderation"), type="FILE_MODERATION").save()
url=reverse("core:file_moderation"), type="FILE_MODERATION").save()
class FileListView(ListView): class FileListView(ListView):

View File

@ -4,6 +4,7 @@ from django.http import JsonResponse
from django.core import serializers from django.core import serializers
from django.db.models import Q from django.db.models import Q
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.views.generic import ListView
import os import os
import json import json
@ -15,10 +16,18 @@ from club.models import Club
def index(request, context=None): def index(request, context=None):
return render(request, "core/index.jinja") 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): def notification(request, notif_id):
notif = Notification.objects.filter(id=notif_id).first() notif = Notification.objects.filter(id=notif_id).first()
if notif: if notif:
notif.delete() notif.viewed = True
notif.save()
return redirect(notif.url) return redirect(notif.url)
return redirect("/") return redirect("/")

View File

@ -270,11 +270,10 @@ class Refilling(models.Model):
self.customer.amount += self.amount self.customer.amount += self.amount
self.customer.save() self.customer.save()
self.is_validated = True self.is_validated = True
Notification( Notification(user=self.customer.user, url=reverse('core:user_account_detail',
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}), 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() ).save()
super(Refilling, self).save(*args, **kwargs) super(Refilling, self).save(*args, **kwargs)
@ -387,9 +386,9 @@ class Selling(models.Model):
user=self.customer.user, user=self.customer.user,
url=reverse('core:user_account_detail', url=reverse('core:user_account_detail',
kwargs={'user_id': self.customer.user.id, 'year': self.date.year, 'month': self.date.month}), 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() ).save()
super(Selling, self).save(*args, **kwargs) super(Selling, self).save(*args, **kwargs)
class Permanency(models.Model): class Permanency(models.Model):

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-09 18:03+0100\n" "POT-Creation-Date: 2016-12-09 23:50+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"
@ -85,12 +85,12 @@ msgstr "Compte club"
msgid "%(club_account)s on %(bank_account)s" msgid "%(club_account)s on %(bank_account)s"
msgstr "%(club_account)s sur %(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 #: launderette/models.py:122
msgid "start date" msgid "start date"
msgstr "date de début" 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" msgid "end date"
msgstr "date de fin" msgstr "date de fin"
@ -124,16 +124,16 @@ msgid "journal"
msgstr "classeur" msgstr "classeur"
#: accounting/models.py:194 core/models.py:515 core/models.py:818 #: accounting/models.py:194 core/models.py:515 core/models.py:818
#: core/models.py:858 counter/models.py:244 counter/models.py:293 #: core/models.py:858 counter/models.py:244 counter/models.py:292
#: counter/models.py:418 eboutic/models.py:15 eboutic/models.py:48 #: counter/models.py:417 eboutic/models.py:15 eboutic/models.py:48
msgid "date" msgid "date"
msgstr "date" msgstr "date"
#: accounting/models.py:195 counter/models.py:419 #: accounting/models.py:195 counter/models.py:418
msgid "comment" msgid "comment"
msgstr "commentaire" 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 #: subscription/models.py:57
msgid "payment method" msgid "payment method"
msgstr "méthode de paiement" msgstr "méthode de paiement"
@ -159,7 +159,7 @@ msgid "accounting type"
msgstr "type comptable" msgstr "type comptable"
#: accounting/models.py:205 accounting/models.py:299 accounting/models.py:325 #: 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" msgid "label"
msgstr "intitulé" msgstr "intitulé"
@ -313,7 +313,7 @@ msgstr "Compte en banque : "
#: counter/templates/counter/last_ops.jinja:59 #: counter/templates/counter/last_ops.jinja:59
#: launderette/templates/launderette/launderette_admin.jinja:16 #: launderette/templates/launderette/launderette_admin.jinja:16
#: launderette/views.py:146 sas/templates/sas/moderation.jinja:36 #: 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" msgid "Delete"
msgstr "Supprimer" 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" msgid "A club with that unix_name already exists"
msgstr "Un club avec ce nom UNIX existe déjà." 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 #: 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" msgid "user"
msgstr "nom d'utilisateur" msgstr "nom d'utilisateur"
@ -843,7 +843,7 @@ msgstr "Membres"
msgid "Old members" msgid "Old members"
msgstr "Anciens membres" 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 #: sas/templates/sas/picture.jinja:83
msgid "Tools" msgid "Tools"
msgstr "Outils" msgstr "Outils"
@ -858,7 +858,7 @@ msgstr "Propriétés"
msgid "Select user" msgid "Select user"
msgstr "Choisir un utilisateur" 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" msgid "You do not have the permission to do that"
msgstr "Vous n'avez pas la permission de faire cela" msgstr "Vous n'avez pas la permission de faire cela"
@ -1299,9 +1299,18 @@ msgstr "contenu de la page"
msgid "url" msgid "url"
msgstr "url" msgstr "url"
#: core/models.py:856 core/models.py:857 #: core/models.py:856
msgid "text" msgid "param"
msgstr "texte" 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 #: core/templates/core/403.jinja:5
msgid "403, Forbidden" msgid "403, Forbidden"
@ -1328,74 +1337,78 @@ msgstr "Connexion"
msgid "Register" msgid "Register"
msgstr "S'enregister" 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" msgid "Logout"
msgstr "Déconnexion" 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" msgid "Search"
msgstr "Recherche" msgstr "Recherche"
#: core/templates/core/base.jinja:79 #: core/templates/core/base.jinja:80
msgid "Main" msgid "Main"
msgstr "Accueil" msgstr "Accueil"
#: core/templates/core/base.jinja:80 #: core/templates/core/base.jinja:81
msgid "Matmatronch" msgid "Matmatronch"
msgstr "Matmatronch" msgstr "Matmatronch"
#: core/templates/core/base.jinja:81 #: core/templates/core/base.jinja:82
msgid "Wiki" msgid "Wiki"
msgstr "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/main.jinja:4 sas/templates/sas/main.jinja.py:8
#: sas/templates/sas/picture.jinja:26 #: sas/templates/sas/picture.jinja:26
msgid "SAS" msgid "SAS"
msgstr "SAS" msgstr "SAS"
#: core/templates/core/base.jinja:83 #: core/templates/core/base.jinja:84
msgid "Forum" msgid "Forum"
msgstr "Forum" msgstr "Forum"
#: core/templates/core/base.jinja:84 #: core/templates/core/base.jinja:85
msgid "Services" msgid "Services"
msgstr "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 #: core/views/files.py:48
msgid "Files" msgid "Files"
msgstr "Fichiers" msgstr "Fichiers"
#: core/templates/core/base.jinja:86 #: core/templates/core/base.jinja:87
msgid "Sponsors" msgid "Sponsors"
msgstr "Partenaires" msgstr "Partenaires"
#: core/templates/core/base.jinja:87 #: core/templates/core/base.jinja:88
msgid "Help" msgid "Help"
msgstr "Aide" msgstr "Aide"
#: core/templates/core/base.jinja:120 #: core/templates/core/base.jinja:121
msgid "Contacts" msgid "Contacts"
msgstr "Contacts" msgstr "Contacts"
#: core/templates/core/base.jinja:121 #: core/templates/core/base.jinja:122
msgid "Legal notices" msgid "Legal notices"
msgstr "Mentions légales" msgstr "Mentions légales"
#: core/templates/core/base.jinja:122 #: core/templates/core/base.jinja:123
msgid "Intellectual property" msgid "Intellectual property"
msgstr "Propriété intellectuelle" msgstr "Propriété intellectuelle"
#: core/templates/core/base.jinja:123 #: core/templates/core/base.jinja:124
msgid "Help & Documentation" msgid "Help & Documentation"
msgstr "Aide & Documentation" msgstr "Aide & Documentation"
#: core/templates/core/base.jinja:124 #: core/templates/core/base.jinja:125
msgid "R&D" msgid "R&D"
msgstr "R&D" msgstr "R&D"
#: core/templates/core/base.jinja:126 #: core/templates/core/base.jinja:127
msgid "Site made by good people" msgid "Site made by good people"
msgstr "Site réalisé par des gens bons" 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_detail.jinja:46
#: core/templates/core/file_moderation.jinja:23 #: 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" msgid "Moderate"
msgstr "Modérer" 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." 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:4
#: core/templates/core/file_moderation.jinja:8 sith/settings.py:456 #: core/templates/core/file_moderation.jinja:8
msgid "File moderation" msgid "File moderation"
msgstr "Modération des fichiers" msgstr "Modération des fichiers"
@ -1633,6 +1646,11 @@ msgstr "L'équipe AE"
msgid "New subscription to the UTBM student association" msgid "New subscription to the UTBM student association"
msgstr "Nouvelle cotisation à l'Association des Étudiants de l'UTBM" 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.jinja:7 core/templates/core/page_list.jinja:4
#: core/templates/core/page_list.jinja:9 #: core/templates/core/page_list.jinja:9
msgid "Page list" 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" msgid "Error uploading file %(file_name)s: %(msg)s"
msgstr "Erreur d'envoi du fichier %(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 #: core/views/forms.py:59 core/views/forms.py:62
msgid "Choose file" msgid "Choose file"
msgstr "Choisir un fichier" msgstr "Choisir un fichier"
@ -2185,7 +2199,7 @@ msgstr "groupe d'achat"
msgid "archived" msgid "archived"
msgstr "archivé" msgstr "archivé"
#: counter/models.py:114 counter/models.py:499 #: counter/models.py:114 counter/models.py:498
msgid "product" msgid "product"
msgstr "produit" msgstr "produit"
@ -2222,7 +2236,7 @@ msgstr "vendeurs"
msgid "token" msgid "token"
msgstr "jeton" 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 #: launderette/models.py:16
msgid "counter" msgid "counter"
msgstr "comptoir" msgstr "comptoir"
@ -2231,7 +2245,7 @@ msgstr "comptoir"
msgid "bank" msgid "bank"
msgstr "banque" msgstr "banque"
#: counter/models.py:249 counter/models.py:296 #: counter/models.py:249 counter/models.py:295
msgid "is validated" msgid "is validated"
msgstr "est validé" msgstr "est validé"
@ -2239,42 +2253,37 @@ msgstr "est validé"
msgid "refilling" msgid "refilling"
msgstr "rechargement" msgstr "rechargement"
#: counter/models.py:277 #: counter/models.py:288 eboutic/models.py:103
#, 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
msgid "unit price" msgid "unit price"
msgstr "prix unitaire" 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" msgid "quantity"
msgstr "quantité" msgstr "quantité"
#: counter/models.py:295 #: counter/models.py:294
msgid "Sith account" msgid "Sith account"
msgstr "Compte utilisateur" 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 #: sith/settings.py:325
msgid "Credit card" msgid "Credit card"
msgstr "Carte bancaire" msgstr "Carte bancaire"
#: counter/models.py:299 #: counter/models.py:298
msgid "selling" msgid "selling"
msgstr "vente" msgstr "vente"
#: counter/models.py:318 #: counter/models.py:317
msgid "Unknown event" msgid "Unknown event"
msgstr "Événement inconnu" msgstr "Événement inconnu"
#: counter/models.py:319 #: counter/models.py:318
#, python-format #, python-format
msgid "Eticket bought for the event %(event)s" msgid "Eticket bought for the event %(event)s"
msgstr "Eticket acheté pour l'événement %(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 #, python-format
msgid "" msgid ""
"You bought an eticket for the event %(event)s.\n" "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 avez acheté un Eticket pour l'événement %(event)s.\n"
"Vous pouvez le télécharger sur cette page: %(url)s" "Vous pouvez le télécharger sur cette page: %(url)s"
#: counter/models.py:390 #: counter/models.py:402
#, python-format
msgid "You just bought %(quantity)d %(product_name)s"
msgstr "Vous avez acheté %(quantity)d %(product_name)s"
#: counter/models.py:403
msgid "last activity date" msgid "last activity date"
msgstr "dernière activité" msgstr "dernière activité"
#: counter/models.py:406 #: counter/models.py:405
msgid "permanency" msgid "permanency"
msgstr "permanence" msgstr "permanence"
#: counter/models.py:420 #: counter/models.py:419
msgid "emptied" msgid "emptied"
msgstr "coffre vidée" msgstr "coffre vidée"
#: counter/models.py:423 #: counter/models.py:422
msgid "cash register summary" msgid "cash register summary"
msgstr "relevé de caisse" msgstr "relevé de caisse"
#: counter/models.py:487 #: counter/models.py:486
msgid "cash summary" msgid "cash summary"
msgstr "relevé" msgstr "relevé"
#: counter/models.py:488 #: counter/models.py:487
msgid "value" msgid "value"
msgstr "valeur" msgstr "valeur"
#: counter/models.py:490 #: counter/models.py:489
msgid "check" msgid "check"
msgstr "chèque" msgstr "chèque"
#: counter/models.py:493 #: counter/models.py:492
msgid "cash register summary item" msgid "cash register summary item"
msgstr "élément de relevé de caisse" msgstr "élément de relevé de caisse"
#: counter/models.py:500 #: counter/models.py:499
msgid "banner" msgid "banner"
msgstr "bannière" msgstr "bannière"
#: counter/models.py:501 #: counter/models.py:500
msgid "event date" msgid "event date"
msgstr "date de l'événement" msgstr "date de l'événement"
#: counter/models.py:502 #: counter/models.py:501
msgid "event title" msgid "event title"
msgstr "titre de l'événement" msgstr "titre de l'événement"
#: counter/models.py:503 #: counter/models.py:502
msgid "secret" msgid "secret"
msgstr "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:45
#: counter/templates/counter/counter_click.jinja:79 #: counter/templates/counter/counter_click.jinja:79
msgid "No date of birth provided" 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:55
#: counter/templates/counter/counter_click.jinja:103 #: counter/templates/counter/counter_click.jinja:103
@ -2764,10 +2768,6 @@ msgstr "Laverie"
msgid "launderette" msgid "launderette"
msgstr "laverie" msgstr "laverie"
#: launderette/models.py:62 launderette/models.py:87 launderette/models.py:123
msgid "type"
msgstr "type"
#: launderette/models.py:63 #: launderette/models.py:63
msgid "is working" msgid "is working"
msgstr "fonctionne" msgstr "fonctionne"
@ -2894,7 +2894,7 @@ msgstr "Utilisateur qui sera conservé"
msgid "User that will be deleted" msgid "User that will be deleted"
msgstr "Utilisateur qui sera supprimé" msgstr "Utilisateur qui sera supprimé"
#: sas/models.py:102 #: sas/models.py:109
msgid "picture" msgid "picture"
msgstr "photo" msgstr "photo"
@ -2913,7 +2913,6 @@ msgid "Create"
msgstr "Créer" msgstr "Créer"
#: sas/templates/sas/moderation.jinja:4 sas/templates/sas/moderation.jinja:8 #: sas/templates/sas/moderation.jinja:4 sas/templates/sas/moderation.jinja:8
#: sith/settings.py:457
msgid "SAS moderation" msgid "SAS moderation"
msgstr "Modération du SAS" msgstr "Modération du SAS"
@ -2966,18 +2965,10 @@ msgstr "Envoyer les images"
msgid "Error creating album %(album)s: %(msg)s" msgid "Error creating album %(album)s: %(msg)s"
msgstr "Erreur de création de l'album %(album)s : %(msg)s" msgstr "Erreur de création de l'album %(album)s : %(msg)s"
#: sas/views.py:54 #: sas/views.py:61
msgid "New pictures/album to be moderated in the SAS"
msgstr "Nouvelles photos/albums à modérer dans le SAS"
#: sas/views.py:62
msgid "Add user" msgid "Add user"
msgstr "Ajouter une personne" 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 #: sith/settings.py:166
msgid "English" msgid "English"
msgstr "Anglais" msgstr "Anglais"
@ -3090,9 +3081,31 @@ msgstr "Membre actif"
msgid "Curious" msgid "Curious"
msgstr "Curieux" 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 #: sith/settings.py:458
msgid "New pictures" msgid "You've been identified on some pictures"
msgstr "Nouvelle photo" 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 #: subscription/models.py:16
msgid "Bad subscription type" msgid "Bad subscription type"

View File

@ -95,7 +95,7 @@
{% if picture.is_moderated %} {% if picture.is_moderated %}
<div id="pict"> <div id="pict">
{% else %} {% else %}
<div id="pict" style="border: solid #f00 2px;"> <div id="pict" style="border: solid #f00 2px; box-shadow: red 0px 0px 5px">
{% set next = picture.get_next() %} {% set next = picture.get_next() %}
{% if not next %} {% if not next %}
{% set next = url('sas:moderation') %} {% set next = url('sas:moderation') %}

View File

@ -51,8 +51,7 @@ class SASForm(forms.Form):
if notif: if notif:
for u in RealGroup.objects.filter(id=settings.SITH_SAS_ADMIN_GROUP_ID).first().users.all(): 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(): if not u.notifications.filter(type="SAS_MODERATION").exists():
Notification(user=u, text=_("New pictures/album to be moderated in the SAS"), Notification(user=u, url=reverse("sas:moderation"), type="SAS_MODERATION").save()
url=reverse("sas:moderation"), type="SAS_MODERATION").save()
class RelationForm(forms.ModelForm): class RelationForm(forms.ModelForm):
class Meta: class Meta:
@ -124,8 +123,7 @@ class PictureView(CanViewMixin, DetailView, FormMixin):
PeoplePictureRelation(user=u, PeoplePictureRelation(user=u,
picture=self.form.cleaned_data['picture']).save() picture=self.form.cleaned_data['picture']).save()
if not u.notifications.filter(type="NEW_PICTURES").exists(): if not u.notifications.filter(type="NEW_PICTURES").exists():
Notification(user=u, text=_("You've been identified on some pictures"), Notification(user=u, url=reverse("core:user_pictures", kwargs={'user_id': u.id}), type="NEW_PICTURES").save()
url=reverse("core:user_pictures", kwargs={'user_id': u.id}), type="NEW_PICTURES").save()
return super(PictureView, self).form_valid(self.form) return super(PictureView, self).form_valid(self.form)
else: else:
self.form.add_error(None, _("You do not have the permission to do that")) self.form.add_error(None, _("You do not have the permission to do that"))

View File

@ -453,9 +453,12 @@ SITH_SAS_ROOT_DIR_ID = 4
SITH_SAS_ADMIN_GROUP_ID = 9 SITH_SAS_ADMIN_GROUP_ID = 9
SITH_NOTIFICATIONS = [ SITH_NOTIFICATIONS = [
('FILE_MODERATION', _("File moderation")), ('FILE_MODERATION', _("New files to be moderated")),
('SAS_MODERATION', _("SAS moderation")), ('SAS_MODERATION', _("New pictures/album to be moderated in the SAS")),
('NEW_PICTURES', _("New pictures")), ('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: try: