|
|
@ -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)
|
|
|
|