add thumbnail in material list view

v1-0-stable
Christian Merten 9 years ago
parent 8726794163
commit d608620b69

@ -42,7 +42,8 @@ class NotTooOldFilter(SimpleListFilter):
class MaterialAdmin(admin.ModelAdmin):
"""Edit view of a MaterialPart"""
list_display = ('name', 'description', 'quantity_real', 'buy_date', 'lifetime', 'not_too_old', 'photo')
list_display = ('name', 'description', 'quantity_real', 'buy_date',
'lifetime', 'not_too_old', 'admin_thumbnail')
inlines = [OwnershipInline]
list_filter = (NotTooOldFilter,)

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-07-05 10:06+0000\n"
"POT-Creation-Date: 2017-07-05 18:57+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -18,74 +18,78 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: material/admin.py:25
#: admin.py:25
msgid "Age"
msgstr "Alter"
#: material/admin.py:30
#: admin.py:30
msgid "Not too old"
msgstr "Nicht zu alt"
#: material/admin.py:31
#: admin.py:31
msgid "Too old"
msgstr "Zu alt"
#: material/apps.py:7
#: apps.py:7
msgid "material"
msgstr "Material"
#: material/models.py:17
#: models.py:17
msgid "name"
msgstr "Name"
#: material/models.py:18
#: models.py:18
msgid "description"
msgstr "Beschreibung"
#: material/models.py:19
#: models.py:19
msgid "quantity"
msgstr "Anzahl"
#: material/models.py:20
#: models.py:20
msgid "purchase date"
msgstr "Kaufdatum"
#: material/models.py:21
#: models.py:21
msgid "lifetime (years)"
msgstr "Lebenszeit (Jahre)"
#: material/models.py:22
#: models.py:22
msgid "photo"
msgstr "Bild"
#: material/models.py:33
#: models.py:33
msgid "Quantity"
msgstr "Anzahl"
#: material/models.py:43
#: models.py:40
msgid "Thumbnail"
msgstr "Bild"
#: models.py:51
msgid "Not too old?"
msgstr "Nicht zu alt?"
#: material/models.py:46
#: models.py:54
msgid "material part"
msgstr "Materialteil"
#: material/models.py:47
#: models.py:55
msgid "material parts"
msgstr "Materialteile"
#: material/models.py:53
#: models.py:61
msgid "owner"
msgstr "Besitzer"
#: material/models.py:54
#: models.py:62
msgid "count"
msgstr "Anzahl"
#: material/models.py:61
#: models.py:69
msgid "ownership"
msgstr "Besitzer"
#: material/models.py:62
#: models.py:70
msgid "ownerships"
msgstr "Verantwortliche"

@ -32,6 +32,14 @@ class MaterialPart(models.Model):
quantity_real.admin_order_field = 'quantity'
quantity_real.short_description = _('Quantity')
def admin_thumbnail(self):
if self.photo:
return '<a href="{0}"><img src="{0}" height="40"></a>'.format(self.photo.url)
else:
return '<i>kein Bild</i>'
admin_thumbnail.short_description = _('Thumbnail')
admin_thumbnail.allow_tags = True
def not_too_old(self):
"""Returns wether the part should be replaced cause of age"""
buy_time = timezone.make_aware(datetime.combine(self.buy_date,

Loading…
Cancel
Save