Ultron/ultron/planning/admin.py

59 lines
1.4 KiB
Python
Raw Normal View History

2021-12-09 16:53:44 +01:00
from django.contrib import admin
from .models import (
EventType,
Event,
2022-01-08 11:40:10 +01:00
EventParticipation,
2021-12-09 16:53:44 +01:00
)
# def duplicate_record(modeladmin, request, queryset):
# '''*Custom action* permettant de dupliquer plusieurs enregistrements.
# '''
2021-12-09 16:53:44 +01:00
# for object in queryset:
# object.id = None
# object.save()
# duplicate_record.short_description = 'Duplicate selected records'
2021-12-09 16:53:44 +01:00
class EventTypeAdmin(admin.ModelAdmin):
model = EventType
2021-12-19 09:30:51 +01:00
list_display = ("name", "acronym")
ordering = ("name",)
search_fields = ("name", "acronym")
2021-12-09 16:53:44 +01:00
2022-01-09 21:48:37 +01:00
class EventAdmin(admin.ModelAdmin):
2021-12-09 16:53:44 +01:00
model = Event
2021-12-19 09:30:51 +01:00
fields = ("name", "eventtype", "place", "datebegin", "dateend", "informations")
list_display = ("name", "eventtype", "place", "datebegin")
ordering = ("name",)
list_filter = ("eventtype",)
search_fields = ("name",)
2022-01-09 21:48:37 +01:00
autocomplete_fields = ("eventtype", "place")
date_hierarchy = "datebegin"
2021-12-09 16:53:44 +01:00
# related_search_fields = {
# 'place': ('name', 'city'),
# }
2021-12-19 09:30:51 +01:00
# filter_horizontal = ('gymnasts', 'club')
# filter_horizontal = ('gymnasts',)
2021-12-09 16:53:44 +01:00
2022-01-07 19:28:33 +01:00
class EventParticipationAdmin(admin.ModelAdmin):
2022-01-08 11:40:10 +01:00
model = EventParticipation
2021-12-09 16:53:44 +01:00
2021-12-19 09:30:51 +01:00
fields = ("event", "gymnast", "rank")
list_display = ("event", "gymnast", "rank")
2022-01-09 21:48:37 +01:00
autocomplete_fields = ("event", "gymnast")
2021-12-09 16:53:44 +01:00
admin.site.register(EventType, EventTypeAdmin)
admin.site.register(Event, EventAdmin)
2022-01-08 11:40:10 +01:00
admin.site.register(EventParticipation, EventParticipationAdmin)