mirror of
https://github.com/Hopiu/django-notifications.git
synced 2026-05-12 07:13:09 +00:00
Add typing to admin
This commit is contained in:
parent
1ec3cc9afd
commit
cdf0013e91
1 changed files with 6 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue