mirror of
https://github.com/ae-utbm/sith.git
synced 2025-06-19 01:25:22 +00:00
display album name on picture identification notif
This commit is contained in:
parent
75b37cd6e3
commit
6fec250658
@ -170,7 +170,6 @@ def news_notification_callback(notif: Notification):
|
||||
if count:
|
||||
notif.viewed = False
|
||||
notif.param = str(count)
|
||||
notif.date = timezone.now()
|
||||
else:
|
||||
notif.viewed = True
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
# Generated by Django 5.2.1 on 2025-06-11 16:10
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
import core.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [("core", "0046_permissionrights")]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name="notification",
|
||||
name="date",
|
||||
field=models.DateTimeField(auto_now=True, verbose_name="date"),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="notification",
|
||||
name="type",
|
||||
field=models.CharField(
|
||||
choices=core.models.get_notification_types,
|
||||
default="GENERIC",
|
||||
max_length=32,
|
||||
verbose_name="type",
|
||||
),
|
||||
),
|
||||
]
|
@ -1451,6 +1451,10 @@ class PageRev(models.Model):
|
||||
return self.page.can_be_edited_by(user)
|
||||
|
||||
|
||||
def get_notification_types():
|
||||
return settings.SITH_NOTIFICATIONS
|
||||
|
||||
|
||||
class Notification(models.Model):
|
||||
user = models.ForeignKey(
|
||||
User, related_name="notifications", on_delete=models.CASCADE
|
||||
@ -1458,9 +1462,9 @@ class Notification(models.Model):
|
||||
url = models.CharField(_("url"), max_length=255)
|
||||
param = models.CharField(_("param"), max_length=128, default="")
|
||||
type = models.CharField(
|
||||
_("type"), max_length=32, choices=settings.SITH_NOTIFICATIONS, default="GENERIC"
|
||||
_("type"), max_length=32, choices=get_notification_types, default="GENERIC"
|
||||
)
|
||||
date = models.DateTimeField(_("date"), default=timezone.now)
|
||||
date = models.DateTimeField(_("date"), auto_now=True)
|
||||
viewed = models.BooleanField(_("viewed"), default=False, db_index=True)
|
||||
|
||||
def __str__(self):
|
||||
|
@ -5103,8 +5103,9 @@ msgid "There are %s pictures to be moderated in the SAS"
|
||||
msgstr "Il y a %s photos à modérer dans le SAS"
|
||||
|
||||
#: sith/settings.py
|
||||
msgid "You've been identified on some pictures"
|
||||
msgstr "Vous avez été identifié sur des photos"
|
||||
#, python-format
|
||||
msgid "You've been identified in album %s"
|
||||
msgstr "Vous avez été identifié dans l'album %s"
|
||||
|
||||
#: sith/settings.py
|
||||
#, python-format
|
||||
|
@ -25,11 +25,10 @@ from django.core.cache import cache
|
||||
from django.db import models
|
||||
from django.db.models import Exists, OuterRef, Q
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from PIL import Image
|
||||
|
||||
from core.models import SithFile, User
|
||||
from core.models import Notification, SithFile, User
|
||||
from core.utils import exif_auto_rotate, resize_image
|
||||
|
||||
|
||||
@ -256,14 +255,10 @@ class Album(SasFile):
|
||||
self.save()
|
||||
|
||||
|
||||
def sas_notification_callback(notif):
|
||||
def sas_notification_callback(notif: Notification):
|
||||
count = Picture.objects.filter(is_moderated=False).count()
|
||||
if count:
|
||||
notif.viewed = False
|
||||
else:
|
||||
notif.viewed = True
|
||||
notif.param = "%s" % count
|
||||
notif.date = timezone.now()
|
||||
notif.viewed = not bool(count)
|
||||
notif.param = str(count)
|
||||
|
||||
|
||||
class PeoplePictureRelation(models.Model):
|
||||
|
@ -677,7 +677,7 @@ SITH_NOTIFICATIONS = [
|
||||
("NEWS_MODERATION", _("There are %s fresh news to be moderated")),
|
||||
("FILE_MODERATION", _("New files to be moderated")),
|
||||
("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 in album %s")),
|
||||
("REFILLING", _("You just refilled of %s €")),
|
||||
("SELLING", _("You just bought %s")),
|
||||
("GENERIC", _("You have a notification")),
|
||||
|
Loading…
x
Reference in New Issue
Block a user