From 9a9b4fd08e0998e694a742c114b211877418ebd5 Mon Sep 17 00:00:00 2001 From: erichhasl Date: Wed, 5 Jul 2017 19:11:37 +0200 Subject: [PATCH] add ownership overview in list view --- jdav_web/material/admin.py | 3 ++- .../material/locale/de/LC_MESSAGES/django.po | 20 +++++++++++-------- jdav_web/material/models.py | 8 ++++++++ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/jdav_web/material/admin.py b/jdav_web/material/admin.py index 8f5ae52..c6228b4 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', + list_display = ('name', 'description', 'quantity_real', + 'ownership_overview', '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 9e82458..211e548 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 18:57+0200\n" +"POT-Creation-Date: 2017-07-05 19:07+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -66,30 +66,34 @@ msgstr "Anzahl" msgid "Thumbnail" msgstr "Bild" -#: models.py:51 +#: models.py:49 +msgid "Owners" +msgstr "Verantwortliche" + +#: models.py:59 msgid "Not too old?" msgstr "Nicht zu alt?" -#: models.py:54 +#: models.py:62 msgid "material part" msgstr "Materialteil" -#: models.py:55 +#: models.py:63 msgid "material parts" msgstr "Materialteile" -#: models.py:61 +#: models.py:69 msgid "owner" msgstr "Besitzer" -#: models.py:62 +#: models.py:70 msgid "count" msgstr "Anzahl" -#: models.py:69 +#: models.py:77 msgid "ownership" msgstr "Besitzer" -#: models.py:70 +#: models.py:78 msgid "ownerships" msgstr "Verantwortliche" diff --git a/jdav_web/material/models.py b/jdav_web/material/models.py index f5cea7b..62ed8d3 100644 --- a/jdav_web/material/models.py +++ b/jdav_web/material/models.py @@ -40,6 +40,14 @@ class MaterialPart(models.Model): admin_thumbnail.short_description = _('Thumbnail') admin_thumbnail.allow_tags = True + def ownership_overview(self): + summary = '' + for owner in self.ownership_set.all(): + summary += '

{}: {}

'.format(str(owner.owner), owner.count) + return summary + ownership_overview.allow_tags = True + ownership_overview.short_description = _('Owners') + 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,