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']
13 readonly_fields = ['created_at']
15 (None, {'fields': ('group', 'sticky', 'created_at')}),
16 (_('Content'), {'fields': ('book', 'text', 'small', 'vip', 'link', 'video', 'picture', 'banner')}),
20 'image', 'image_shift', 'image_title', 'image_author',
21 'image_link', 'image_license', 'image_license_link')},
25 def nonempty_text(self, cite):
28 return "(%s)" % (cite.image_title.strip() or cite.link)
29 nonempty_text.short_description = _('text')
31 def has_image(self, cite):
32 return bool(cite.image)
33 has_image.short_description = _('image')
34 has_image.boolean = True
37 admin.site.register(Cite, CiteAdmin)
40 class BannerGroupAdmin(admin.ModelAdmin):
41 list_display = ['name', 'created_at']
42 fields = ['name', 'created_at']
43 readonly_fields = ['created_at']
45 admin.site.register(BannerGroup, BannerGroupAdmin)
48 class CarouselItemInline(OrderableAdmin, admin.TabularInline):
50 ordering_field = 'order'
53 class CarouselAdmin(admin.ModelAdmin):
54 inlines = [CarouselItemInline]
57 admin.site.register(Carousel, CarouselAdmin)