2
0
Fork 0

Extend 'Message' model admin

This commit is contained in:
Luca 2023-05-06 23:47:43 +02:00
parent ff3e489e22
commit 5ce4c44b6a
2 changed files with 25 additions and 1 deletions

View File

@ -57,5 +57,28 @@ class ShiftRegistrationAdmin(admin.ModelAdmin):
return obj.helper.name
admin.site.register(Message)
class WasSentListFilter(admin.SimpleListFilter):
parameter_name = "sent"
title = "sent status"
def lookups(self, request, model_admin):
return [("0", "Not sent"), ("1", "Sent")]
def queryset(self, request, queryset):
if self.value() == "1":
return queryset.exclude(sent_at=None)
elif self.value() == "0":
return queryset.filter(sent_at=None)
@admin.register(Message)
class MessageAdmin(admin.ModelAdmin):
list_display = ("__str__", "was_sent")
list_filter = (WasSentListFilter,)
@admin.display(boolean=True)
def was_sent(self, obj):
return obj.sent_at is not None
admin.site.register(LoginToken)

View File

@ -4,6 +4,7 @@ from .models import TeamMember
# Register your models here.
@admin.register(TeamMember)
class TeamMemberAdmin(admin.ModelAdmin):
fields = ["name"]