47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Django admin interface for the event app.
|
|
|
|
It's the best way to add eventseries, or edit/delete events."""
|
|
from django.contrib import admin
|
|
from django.utils.translation import gettext as _
|
|
|
|
from events.models import Event, Photo, Location
|
|
|
|
|
|
class EventInline(admin.TabularInline):
|
|
"""To list events of an eventseries below the 'master event'"""
|
|
model = Event
|
|
fields = ('name', 'start', 'end')
|
|
verbose_name_plural = _('Event Series')
|
|
|
|
|
|
class EventAdmin(admin.ModelAdmin):
|
|
"""Admin Interface to list and edit events."""
|
|
list_display = ('name', 'start', 'end', 'location',)
|
|
list_editable = ('start', 'end', 'location')
|
|
readonly_fields = ('event_series',)
|
|
date_hierarchy = 'start'
|
|
search_fields = ('name', 'description')
|
|
list_per_page = 50
|
|
inlines = (EventInline,)
|
|
|
|
|
|
class LocationAdmin(admin.ModelAdmin):
|
|
"""Admin Interace to list and edit event locations."""
|
|
list_display = ('name', 'street_address', 'postal_code', 'locality')
|
|
|
|
|
|
class PhotoAdmin(admin.ModelAdmin):
|
|
"""Admin Interface to list and edit photos of events."""
|
|
fields = ('image', 'event', 'name', 'description',
|
|
('photographer', 'created_date'))
|
|
list_filter = ('event', 'on_startpage',)
|
|
list_display = ('image', 'image', 'name', 'event',
|
|
'photographer', 'on_startpage')
|
|
list_display_links = ('image',)
|
|
list_editable = ('on_startpage', 'name', 'event', 'photographer')
|
|
|
|
|
|
admin.site.register(Event, EventAdmin)
|
|
admin.site.register(Photo, PhotoAdmin)
|
|
admin.site.register(Location, LocationAdmin)
|