From cdf0013e91156f87898a8a60404fd4de625b9618 Mon Sep 17 00:00:00 2001 From: Alvaro Mariano Date: Thu, 13 Jul 2023 00:28:01 +0000 Subject: [PATCH] Add typing to admin --- notifications/admin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/notifications/admin.py b/notifications/admin.py index 27f3eaf..0bdba5b 100644 --- a/notifications/admin.py +++ b/notifications/admin.py @@ -1,9 +1,12 @@ """ Django notifications admin file """ # -*- coding: utf-8 -*- from django.contrib import admin +from django.http import HttpRequest from django.utils.translation import gettext_lazy from swapper import load_model +from notifications.querysets import NotificationQuerySet + Notification = load_model("notifications", "Notification") @@ -20,14 +23,14 @@ class NotificationAdmin(admin.ModelAdmin): ) actions = ("mark_unread", "mark_read") - def get_queryset(self, request): + def get_queryset(self, request: HttpRequest): qs = super().get_queryset(request) return qs.prefetch_related("actor") @admin.action(description=gettext_lazy("Mark selected notifications as unread")) - def mark_unread(self, request, queryset): + def mark_unread(self, request: HttpRequest, queryset: NotificationQuerySet): queryset.update(unread=True) @admin.action(description=gettext_lazy("Mark selected notifications as read")) - def mark_read(self, request, queryset): + def mark_read(self, request: HttpRequest, queryset: NotificationQuerySet): queryset.update(unread=False)