poulpe/event/admin.py

51 lines
1.6 KiB
Python
Raw Normal View History

from django.contrib import admin
2018-08-20 15:16:40 +02:00
from shared.admin import admin_site
2018-08-20 16:02:42 +02:00
from .models import Event, Place, ActivityTag, Activity, ActivityTemplate # TODO add me
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', ]
class AbstractActivityTemplateAdmin(admin.ModelAdmin):
list_display = ['title', 'event', 'is_public', ]
ordering = ['title', 'event', 'has_perm', ]
search_fields = ['title', 'description', 'remark', ]
list_filter = ['event', 'is_public', 'has_perm', 'tags', ]
class ActivityTemplateAdmin(AbstractActivityTemplateAdmin):
pass
class ActivityAdmin(AbstractActivityTemplateAdmin):
pass
#exclude = ['parent', ] # TODO remove me
2018-08-20 15:16:40 +02:00
admin_site.register(Event, EventAdmin)
2018-08-20 16:02:42 +02:00
admin_site.register(Place, PlaceAdmin)
admin_site.register(ActivityTag, ActivityTagAdmin)
admin_site.register(ActivityTemplate, ActivityTemplateAdmin)
admin_site.register(Activity, ActivityAdmin)