diff --git a/shiftregister/app/admin.py b/shiftregister/app/admin.py index 4ca97f9..d712fb4 100644 --- a/shiftregister/app/admin.py +++ b/shiftregister/app/admin.py @@ -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) diff --git a/shiftregister/fallback/admin.py b/shiftregister/fallback/admin.py index 32ed3e2..e2c1858 100644 --- a/shiftregister/fallback/admin.py +++ b/shiftregister/fallback/admin.py @@ -4,6 +4,7 @@ from .models import TeamMember # Register your models here. + @admin.register(TeamMember) class TeamMemberAdmin(admin.ModelAdmin): fields = ["name"]