-
Notifications
You must be signed in to change notification settings - Fork 619
/
Copy pathadmin.py
31 lines (21 loc) · 931 Bytes
/
admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from django.contrib import admin
from django.db.models.functions import Lower
from nominations.models import Election, Nominee, Nomination
@admin.register(Election)
class ElectionAdmin(admin.ModelAdmin):
readonly_fields = ("slug",)
@admin.register(Nominee)
class NomineeAdmin(admin.ModelAdmin):
raw_id_fields = ("user",)
list_display = ("__str__", "election", "accepted", "approved")
list_filter = ("election", "accepted", "approved")
readonly_fields = ("slug",)
def get_ordering(self, request):
return ['election', Lower('user__last_name')]
@admin.register(Nomination)
class NominationAdmin(admin.ModelAdmin):
raw_id_fields = ("nominee", "nominator")
list_display = ("__str__", "election", "accepted", "approved", "nominee")
list_filter = ("election", "accepted", "approved")
def get_ordering(self, request):
return ['election', Lower('nominee__user__last_name')]