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):
|
2021-12-17 09:44:28 +01:00
|
|
|
# '''*Custom action* permettant de dupliquer plusieurs enregistrements.
|
|
|
|
# '''
|
2021-12-09 16:53:44 +01:00
|
|
|
# for object in queryset:
|
|
|
|
# object.id = None
|
|
|
|
# object.save()
|
|
|
|
|
|
|
|
|
2021-12-17 09:44:28 +01:00
|
|
|
# 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")
|
2022-01-09 21:20:06 +01:00
|
|
|
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')
|
2021-12-17 09:44:28 +01:00
|
|
|
# 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)
|