X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/b2d342589a7889a3b096e7192453d53bd28eed7d..f177dd0cdb753827bd208960a159d1bbbaae9e80:/src/social/admin.py diff --git a/src/social/admin.py b/src/social/admin.py index a0f3ec92b..bceb89008 100755 --- a/src/social/admin.py +++ b/src/social/admin.py @@ -1,17 +1,19 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django.contrib import admin from django.utils.translation import ugettext_lazy as _ - -from social.models import Cite +from admin_ordering.admin import OrderableAdmin +from social.models import Cite, BannerGroup, Carousel, CarouselItem class CiteAdmin(admin.ModelAdmin): - list_display = ['nonempty_text', 'sticky', 'vip', 'small', 'has_image'] + list_display = ['nonempty_text', 'created_at', 'sticky', 'vip', 'small', 'has_image'] + list_filter = ['group'] + readonly_fields = ['created_at'] fieldsets = ( - (None, {'fields': ('book', 'text', 'small', 'vip', 'link', 'sticky')}), + (None, {'fields': ('group', 'sticky', 'created_at')}), + (_('Content'), {'fields': ('book', 'text', 'small', 'vip', 'link', 'video', 'picture', 'banner')}), ( _('Background'), {'fields': ( @@ -23,7 +25,7 @@ class CiteAdmin(admin.ModelAdmin): def nonempty_text(self, cite): if cite.text.strip(): return cite.text - return "(%s)" % (cite.image_title.strip() or cite.link) + return "(%s)" % ((cite.image_title or '').strip() or cite.link) nonempty_text.short_description = _('text') def has_image(self, cite): @@ -33,3 +35,24 @@ class CiteAdmin(admin.ModelAdmin): admin.site.register(Cite, CiteAdmin) + + +class BannerGroupAdmin(admin.ModelAdmin): + list_display = ['name', 'created_at'] + fields = ['name', 'created_at'] + readonly_fields = ['created_at'] + +admin.site.register(BannerGroup, BannerGroupAdmin) + + +class CarouselItemInline(OrderableAdmin, admin.TabularInline): + model = CarouselItem + ordering_field = 'order' + + +class CarouselAdmin(admin.ModelAdmin): + inlines = [CarouselItemInline] + + +admin.site.register(Carousel, CarouselAdmin) +