From e65e5eb2e6b51787aeb14abfe7bbbeac96f43fec Mon Sep 17 00:00:00 2001 From: "Andreas (@xAndy) Zimmermann" Date: Thu, 26 May 2022 17:20:47 +0200 Subject: [PATCH] add sort and filter to shift registrations --- shiftregister/app/admin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/shiftregister/app/admin.py b/shiftregister/app/admin.py index a0a3037..4ca97f9 100644 --- a/shiftregister/app/admin.py +++ b/shiftregister/app/admin.py @@ -1,4 +1,5 @@ from django.contrib import admin +from django.contrib.admin import DateFieldListFilter from .models import Room, Shift, Helper, ShiftRegistration, Message, LoginToken @@ -42,6 +43,7 @@ class HelperAdmin(admin.ModelAdmin): @admin.register(ShiftRegistration) class ShiftRegistrationAdmin(admin.ModelAdmin): list_display = ("start_at", "room", "helper_name", "state") + list_filter = (("shift__start_at", DateFieldListFilter), "shift__room", "state") def room(self, obj): return obj.shift.room.name @@ -49,6 +51,8 @@ class ShiftRegistrationAdmin(admin.ModelAdmin): def start_at(self, obj): return obj.shift.start_at + start_at.admin_order_field = "shift__start_at" + def helper_name(self, obj): return obj.helper.name