""" Newforms Admin configuration for Darkroom

"""
from django.contrib import admin
from models import *

PER_PAGE = 50


class MovieAdmin(admin.ModelAdmin):
    list_display = ("title", "slug", "created", "published")
    list_filter = ["created", "published"]
    list_per_page = PER_PAGE


admin.site.register(Movie, MovieAdmin)


class GalleryAdmin(admin.ModelAdmin):
    list_display = ("title", "slug", "created", "photo_count", "published")
    list_filter = ["created", "published"]
    date_hierarchy = "created"
    filter_horizontal = (
        "towns",
        "sites",
        "photos",
    )


class PhotographerAdmin(admin.ModelAdmin):
    list_display = ("name",)
    list_filter = ["created"]
    list_per_page = PER_PAGE


class PhotoAdmin(admin.ModelAdmin):
    list_display = (
        "title",
        "slug",
        "created",
        "published",
        "view_count",
        "admin_thumbnail",
    )
    list_filter = ["created", "published"]
    list_per_page = PER_PAGE
    search_fields = (
        "title",
        "description",
        "photographer__name",
    )
    filter_horizontal = (
        "towns",
        "sites",
    )
    fieldsets = (
        (
            None,
            {
                "fields": (
                    "title",
                    "slug",
                    "description",
                    "image",
                    "photographer",
                    "courtesy",
                    "file_photo",
                )
            },
        ),
        (
            "Publishing",
            {
                "fields": (
                    "weight",
                    "published",
                    "published_on",
                    "tags",
                    "towns",
                    "sites",
                )
            },
        ),
        ("Presentation", {"fields": ("crop_from", "effect", "orientation")}),
    )


class PhotoEffectAdmin(admin.ModelAdmin):
    list_display = ("name", "description", "admin_sample")
    fieldsets = (
        (None, {"fields": ("name", "description")}),
        ("Adjustments", {"fields": ("color", "brightness", "contrast", "sharpness")}),
        ("Filters", {"fields": ("filters",)}),
        (
            "Reflection",
            {"fields": ("reflection_size", "reflection_strength", "background_color")},
        ),
    )


class PhotoSizeAdmin(admin.ModelAdmin):
    list_display = (
        "name",
        "width",
        "height",
        "crop",
        "pre_cache",
        "effect",
        "increment_count",
    )
    fieldsets = (
        (None, {"fields": ("name", "width", "height", "quality")}),
        ("Options", {"fields": ("upscale", "crop", "pre_cache", "increment_count")}),
        ("Enhancements", {"fields": ("effect", "watermark",)}),
    )


class WatermarkAdmin(admin.ModelAdmin):
    list_display = ("name", "opacity", "style")


class GraphicAdmin(admin.ModelAdmin):
    list_display = (
        "title",
        "slug",
        "created",
        "published",
        "view_count",
        "admin_thumbnail",
    )
    list_filter = ["created", "published"]
    list_per_page = PER_PAGE


admin.site.register(Graphic, GraphicAdmin)

admin.site.register(Gallery, GalleryAdmin)
admin.site.register(GalleryUpload)
admin.site.register(Slideshow)
admin.site.register(SlideshowUpload)
admin.site.register(Photographer, PhotographerAdmin)
admin.site.register(Photo, PhotoAdmin)
admin.site.register(PhotoEffect, PhotoEffectAdmin)
admin.site.register(PhotoSize, PhotoSizeAdmin)
admin.site.register(Watermark, WatermarkAdmin)
admin.site.register(Webcam)
