2016-09-30 20:10:35 +02:00
|
|
|
from django.contrib import admin
|
|
|
|
|
2018-08-20 16:02:42 +02:00
|
|
|
from .models import Event, Place, ActivityTag, Activity, ActivityTemplate # TODO add me
|
2018-08-26 21:18:51 +02:00
|
|
|
from equipment.models import EquipmentAttribution
|
|
|
|
|
|
|
|
|
|
|
|
class EquipmentAttributionExtraInline(admin.TabularInline):
|
|
|
|
model = EquipmentAttribution
|
|
|
|
extra = 0
|
|
|
|
classes = ['collapse']
|
2018-08-20 15:16:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
class EventAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ['title', 'slug', 'beginning_date', 'ending_date']
|
|
|
|
readonly_fields = ['created_by', 'created_at', ]
|
|
|
|
ordering = ['title', 'beginning_date', 'ending_date', ]
|
|
|
|
search_fields = ['title', 'decription', ]
|
2018-08-20 16:02:42 +02:00
|
|
|
list_filter = ['beginning_date', 'ending_date', ]
|
2018-08-20 15:16:40 +02:00
|
|
|
date_hierarchy = 'beginning_date'
|
|
|
|
|
2018-08-20 16:02:42 +02:00
|
|
|
|
|
|
|
class PlaceAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ['name', 'event', ]
|
|
|
|
ordering = ['name', 'event', ]
|
|
|
|
search_fields = ['name', ]
|
|
|
|
list_filter = ['event', ]
|
|
|
|
|
|
|
|
|
|
|
|
class ActivityTagAdmin(admin.ModelAdmin):
|
|
|
|
list_display = ['name', 'event', 'is_public', ]
|
|
|
|
ordering = ['name', 'event', 'is_public', ]
|
|
|
|
search_fields = ['name', ]
|
|
|
|
list_filter = ['event', 'is_public', ]
|
|
|
|
|
|
|
|
|
2018-08-20 18:20:18 +02:00
|
|
|
class ActivityTemplateAdmin(admin.ModelAdmin):
|
2018-08-26 21:18:51 +02:00
|
|
|
save_as_continue = True
|
|
|
|
save_on_top = True
|
2018-08-20 18:20:18 +02:00
|
|
|
list_display = ['name', 'title', 'event', 'is_public', ]
|
|
|
|
ordering = ['name', 'title', 'event', 'has_perm', ]
|
|
|
|
search_fields = ['name', 'title', 'description', 'remark', ]
|
2018-08-20 16:02:42 +02:00
|
|
|
list_filter = ['event', 'is_public', 'has_perm', 'tags', ]
|
2018-08-20 18:20:18 +02:00
|
|
|
filter_horizontal = ['tags', 'places', ]
|
|
|
|
fieldsets = (
|
|
|
|
('Identifiant', {
|
|
|
|
'fields': ('name', ),
|
|
|
|
}),
|
|
|
|
('Général', {
|
|
|
|
'fields': ('event', 'title', 'is_public', 'places', ),
|
|
|
|
'description': "Tous ces champs sont héritables (Sauf Évènement)",
|
|
|
|
}),
|
|
|
|
('Permanences', {
|
|
|
|
'fields': ('has_perm', ('min_perm', 'max_perm', ), ),
|
|
|
|
'classes': ('collapse',),
|
|
|
|
'description': "Tous ces champs sont héritables",
|
|
|
|
}),
|
|
|
|
('Descriptions', {
|
|
|
|
'fields': ('description', 'tags', 'remarks', ),
|
|
|
|
'classes': ('collapse',),
|
|
|
|
'description': "Tous ces champs sont héritables",
|
|
|
|
}),
|
|
|
|
)
|
2018-08-20 16:02:42 +02:00
|
|
|
|
|
|
|
|
2018-08-20 18:20:18 +02:00
|
|
|
class ActivityAdmin(admin.ModelAdmin):
|
2018-08-27 15:31:44 +02:00
|
|
|
save_as = True
|
2018-08-26 21:18:51 +02:00
|
|
|
save_on_top = True
|
2018-08-20 18:20:18 +02:00
|
|
|
list_display = ['title', 'event', 'is_public', 'parent', ]
|
|
|
|
ordering = ['title', 'event', 'has_perm', 'parent', ]
|
|
|
|
search_fields = ['title', 'description', 'remark', ]
|
|
|
|
list_filter = ['event', 'is_public', 'has_perm', 'tags', ]
|
2018-08-26 21:18:51 +02:00
|
|
|
filter_horizontal = ['tags', 'places', 'staff', ]
|
|
|
|
inlines = [EquipmentAttributionExtraInline, ]
|
2018-08-20 18:20:18 +02:00
|
|
|
fieldsets = (
|
|
|
|
('Général', {
|
2018-08-27 15:31:44 +02:00
|
|
|
'fields': ('event', 'parent', 'title', 'is_public', 'beginning', 'end', 'places', ),
|
2018-08-20 18:20:18 +02:00
|
|
|
'description': "Tous ces champs sont héritables (sauf parent et Évènement)",
|
|
|
|
}),
|
|
|
|
('Permanences', {
|
2018-08-26 21:18:51 +02:00
|
|
|
'fields': ('has_perm', ('min_perm', 'max_perm', ), 'staff', ),
|
2018-08-27 15:31:44 +02:00
|
|
|
'classes': ('wide',),
|
2018-08-20 18:20:18 +02:00
|
|
|
'description': "Tous ces champs sont héritables (sauf les gens en perm)",
|
|
|
|
}),
|
|
|
|
('Descriptions', {
|
2018-08-26 21:18:51 +02:00
|
|
|
'fields': ('description', 'tags', 'remarks', ),
|
2018-08-20 18:20:18 +02:00
|
|
|
'classes': ('collapse',),
|
|
|
|
'description': "Tous ces champs sont héritables",
|
|
|
|
}),
|
|
|
|
)
|
2018-08-20 16:02:42 +02:00
|
|
|
|
|
|
|
|
2018-08-27 14:03:06 +02:00
|
|
|
admin.site.register(Event, EventAdmin)
|
|
|
|
admin.site.register(Place, PlaceAdmin)
|
|
|
|
admin.site.register(ActivityTag, ActivityTagAdmin)
|
|
|
|
admin.site.register(ActivityTemplate, ActivityTemplateAdmin)
|
|
|
|
admin.site.register(Activity, ActivityAdmin)
|