1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from django.contrib import admin
5 from django.utils.translation import ugettext_lazy as _
6 from admin_ordering.admin import OrderableAdmin
7 from social.models import Cite, BannerGroup, Carousel, CarouselItem
10 class CiteAdmin(admin.ModelAdmin):
11 list_display = ['nonempty_text', 'created_at', 'sticky', 'vip', 'small', 'has_image']
12 list_filter = ['group']
14 (None, {'fields': ('group', 'sticky')}),
15 (_('Content'), {'fields': ('book', 'text', 'small', 'vip', 'link', 'video', 'picture', 'banner')}),
19 'image', 'image_shift', 'image_title', 'image_author',
20 'image_link', 'image_license', 'image_license_link')},
24 def nonempty_text(self, cite):
27 return "(%s)" % (cite.image_title.strip() or cite.link)
28 nonempty_text.short_description = _('text')
30 def has_image(self, cite):
31 return bool(cite.image)
32 has_image.short_description = _('image')
33 has_image.boolean = True
36 admin.site.register(Cite, CiteAdmin)
38 admin.site.register(BannerGroup)
41 class CarouselItemInline(OrderableAdmin, admin.TabularInline):
43 ordering_field = 'order'
46 class CarouselAdmin(admin.ModelAdmin):
47 inlines = [CarouselItemInline]
50 admin.site.register(Carousel, CarouselAdmin)