Extend 'Message' model admin

pull/1/head
Luca 2 years ago
parent ff3e489e22
commit 5ce4c44b6a

@ -57,5 +57,28 @@ class ShiftRegistrationAdmin(admin.ModelAdmin):
return obj.helper.name 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) admin.site.register(LoginToken)

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

Loading…
Cancel
Save