Sith/election/admin.py

37 lines
919 B
Python
Raw Normal View History

2016-12-05 19:18:03 +00:00
from django.contrib import admin
2024-06-24 11:07:36 +00:00
from election.models import Candidature, Election, ElectionList, Role
2022-12-19 19:55:33 +00:00
@admin.register(Election)
class ElectionAdmin(admin.ModelAdmin):
list_display = (
"title",
"is_candidature_active",
"is_vote_active",
"is_vote_finished",
"archived",
)
2024-07-29 22:56:13 +00:00
autocomplete_fields = ("voters",)
2022-12-19 19:55:33 +00:00
@admin.register(Role)
class RoleAdmin(admin.ModelAdmin):
list_display = ("election", "title", "max_choice")
search_fields = ("election__title", "title")
@admin.register(ElectionList)
class ElectionListAdmin(admin.ModelAdmin):
list_display = ("election", "title")
search_fields = ("election__title", "title")
@admin.register(Candidature)
class CandidatureAdmin(admin.ModelAdmin):
list_display = ("user", "role", "election_list")
2024-07-29 22:56:13 +00:00
autocomplete_fields = ("user",)
2022-12-19 19:55:33 +00:00
# Votes must stay fully anonymous, so no ModelAdmin for Vote model