mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
enhance admin pages
This commit is contained in:
@ -1,3 +1,37 @@
|
||||
from ajax_select import make_ajax_form
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
from election.models import Election, Role, ElectionList, Candidature
|
||||
|
||||
|
||||
@admin.register(Election)
|
||||
class ElectionAdmin(admin.ModelAdmin):
|
||||
list_display = (
|
||||
"title",
|
||||
"is_candidature_active",
|
||||
"is_vote_active",
|
||||
"is_vote_finished",
|
||||
"archived",
|
||||
)
|
||||
form = make_ajax_form(Election, {"voters": "users"})
|
||||
|
||||
|
||||
@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")
|
||||
form = make_ajax_form(Candidature, {"user": "users"})
|
||||
|
||||
|
||||
# Votes must stay fully anonymous, so no ModelAdmin for Vote model
|
||||
|
Reference in New Issue
Block a user