mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Refactor notifications
This commit is contained in:
@ -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):
|
||||
|
@ -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("/")
|
||||
|
||||
|
Reference in New Issue
Block a user