Skip to content

Commit 0fc4be8

Browse files
committed
add helpers to admin for nomination management
1 parent 988723f commit 0fc4be8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

nominations/admin.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from django.contrib import admin
22

3+
from django.db.models.functions import Lower
4+
35
from nominations.models import Election, Nominee, Nomination
46

57

@@ -15,9 +17,15 @@ class NomineeAdmin(admin.ModelAdmin):
1517
list_filter = ("election", "accepted", "approved")
1618
readonly_fields = ("slug",)
1719

20+
def get_ordering(self, request):
21+
return ['election', Lower('user__last_name')]
22+
1823

1924
@admin.register(Nomination)
2025
class NominationAdmin(admin.ModelAdmin):
2126
raw_id_fields = ("nominee", "nominator")
22-
list_display = ("__str__", "election", "accepted", "approved")
27+
list_display = ("__str__", "election", "accepted", "approved", "nominee")
2328
list_filter = ("election", "accepted", "approved")
29+
30+
def get_ordering(self, request):
31+
return ['election', Lower('nominee__user__last_name')]

0 commit comments

Comments
 (0)