translation update
[wolnelektury.git] / src / social / admin.py
1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 #
5 from django.contrib import admin
6 from django.utils.translation import ugettext_lazy as _
7
8 from social.models import Cite
9
10
11 class CiteAdmin(admin.ModelAdmin):
12     list_display = ['nonempty_text', 'sticky', 'vip', 'small', 'has_image']
13     fieldsets = (
14         (None, {'fields': ('book', 'text', 'small', 'vip', 'link', 'sticky', 'banner')}),
15         (
16             _('Background'),
17             {'fields': (
18                 'image', 'image_shift', 'image_title', 'image_author',
19                 'image_link', 'image_license', 'image_license_link')},
20         )
21     )
22
23     def nonempty_text(self, cite):
24         if cite.text.strip():
25             return cite.text
26         return "(%s)" % (cite.image_title.strip() or cite.link)
27     nonempty_text.short_description = _('text')
28
29     def has_image(self, cite):
30         return bool(cite.image)
31     has_image.short_description = _('image')
32     has_image.boolean = True
33
34
35 admin.site.register(Cite, CiteAdmin)