"""
Created on 19.09.2011

@author: christian
"""
# import stuff we need from django
from django.contrib import admin
from imagekit.admin import AdminThumbnail
from django.utils.translation import gettext as _

from events.models import Event, Photo, Location


class EventInline(admin.TabularInline):
    model = Event
    fields = ('name', 'start', 'end')
    verbose_name_plural = _('Event Series')


class EventAdmin(admin.ModelAdmin):
    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):
    list_display = ('name', 'street_address', 'postal_code', 'locality')


class PhotoAdmin(admin.ModelAdmin):
    admin_thumbnail = AdminThumbnail(image_field='thumbnail')
    fields = ('image', 'event', 'name', 'description',
              ('anchor_horizontal', 'anchor_vertical'),
              ('photographer', 'created_date'))
    list_filter = ('event', 'on_startpage',)
    list_display = ('admin_thumbnail', 'image', 'name', 'event',
                    'photographer', 'on_startpage')
    list_display_links = ('image',)
    list_editable = ('on_startpage', 'name', 'event', 'photographer')


# register with CMS

admin.site.register(Event, EventAdmin)
admin.site.register(Photo, PhotoAdmin)
admin.site.register(Location, LocationAdmin)
