mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
core, com: make permanent notifications for news to moderate
This needs to be made for other stuff, like the SAS or the files... Signed-off-by: Skia <skia@libskia.so>
This commit is contained in:
@ -27,6 +27,7 @@ from django.http import JsonResponse
|
||||
from django.core import serializers
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.views.generic import ListView, TemplateView
|
||||
from django.conf import settings
|
||||
|
||||
import json
|
||||
|
||||
@ -50,15 +51,18 @@ class NotificationList(ListView):
|
||||
|
||||
def get_queryset(self):
|
||||
if 'see_all' in self.request.GET.keys():
|
||||
self.request.user.notifications.update(viewed=True)
|
||||
for n in self.request.user.notifications.all():
|
||||
n.viewed = True
|
||||
n.save()
|
||||
return self.request.user.notifications.order_by('-date')[:20]
|
||||
|
||||
|
||||
def notification(request, notif_id):
|
||||
notif = Notification.objects.filter(id=notif_id).first()
|
||||
if notif:
|
||||
notif.viewed = True
|
||||
notif.save()
|
||||
if notif.type not in settings.SITH_PERMANENT_NOTIFICATIONS:
|
||||
notif.viewed = True
|
||||
notif.save()
|
||||
return redirect(notif.url)
|
||||
return redirect("/")
|
||||
|
||||
|
Reference in New Issue
Block a user