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:
Skia
2017-09-06 13:16:28 +02:00
parent dd5926b404
commit 0184b9c29b
5 changed files with 66 additions and 5 deletions

View File

@ -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("/")