Extend 'Message' model admin
This commit is contained in:
parent
ff3e489e22
commit
5ce4c44b6a
|
@ -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)
|
||||
|
|
|
@ -4,6 +4,7 @@ from .models import TeamMember
|
|||
|
||||
# Register your models here.
|
||||
|
||||
|
||||
@admin.register(TeamMember)
|
||||
class TeamMemberAdmin(admin.ModelAdmin):
|
||||
fields = ["name"]
|
||||
|
|
Loading…
Reference in New Issue