From d608620b697ea8093886b8b867334b890093d8cb Mon Sep 17 00:00:00 2001 From: erichhasl Date: Wed, 5 Jul 2017 18:58:40 +0200 Subject: [PATCH] add thumbnail in material list view --- jdav_web/material/admin.py | 3 +- .../material/locale/de/LC_MESSAGES/django.po | 42 ++++++++++--------- jdav_web/material/models.py | 8 ++++ 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/jdav_web/material/admin.py b/jdav_web/material/admin.py index 0753758..8f5ae52 100644 --- a/jdav_web/material/admin.py +++ b/jdav_web/material/admin.py @@ -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,) diff --git a/jdav_web/material/locale/de/LC_MESSAGES/django.po b/jdav_web/material/locale/de/LC_MESSAGES/django.po index 5291c10..9e82458 100644 --- a/jdav_web/material/locale/de/LC_MESSAGES/django.po +++ b/jdav_web/material/locale/de/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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" diff --git a/jdav_web/material/models.py b/jdav_web/material/models.py index e9ba04f..f5cea7b 100644 --- a/jdav_web/material/models.py +++ b/jdav_web/material/models.py @@ -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 ''.format(self.photo.url) + else: + return 'kein Bild' + 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,