Ultron/followup/admin.py

58 lines
1.5 KiB
Python

from django.contrib import admin
from .models import Chrono, LearnedSkill, Skill, Point
from django_extensions.admin import ForeignKeyAutocompleteAdmin
class ChronoAdmin(ForeignKeyAutocompleteAdmin):
model = Chrono
list_display = ('date', 'gymnast', 'score', 'type')
list_filter = ('type', )
# search_fields = ('gymnast', 'routine')
autocomplete_fields = ['gymnast']
related_search_fields = {
'gymnast': ('last_name', 'first_name')
}
class SkillAdmin(admin.ModelAdmin):
model = Skill
list_display = ('short_label', 'numeric_notation', 'difficulty', 'level', 'rank')
list_filter = ('difficulty', 'level', 'rank')
search_fields = ('short_label', )
# autocomplete_fields = ['ancestor']
# related_search_fields = {
# 'gymnast': ('last_name', 'first_name')
# }
class LearnedSkillAdmin(admin.ModelAdmin):
model = LearnedSkill
list_display = ('gymnast', 'skill', 'cando', 'date')
list_filter = ('gymnast', 'skill', 'cando')
search_fields = ('gymnast', 'skill')
autocomplete_fields = ['gymnast', 'skill']
class PointAdmin(admin.ModelAdmin):
model = Point
list_display = (
"gymnast",
"point_execution",
"point_difficulty",
"point_time_of_flight",
"total",
)
ordering = ("gymnast",)
list_filter = ("gymnast", "event", "routine_type")
admin.site.register(Point, PointAdmin)
admin.site.register(Chrono, ChronoAdmin)
admin.site.register(LearnedSkill, LearnedSkillAdmin)
admin.site.register(Skill, SkillAdmin)