add ownership overview in list view

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

@ -42,7 +42,8 @@ class NotTooOldFilter(SimpleListFilter):
class MaterialAdmin(admin.ModelAdmin): class MaterialAdmin(admin.ModelAdmin):
"""Edit view of a MaterialPart""" """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') 'lifetime', 'not_too_old', 'admin_thumbnail')
inlines = [OwnershipInline] inlines = [OwnershipInline]
list_filter = (NotTooOldFilter,) list_filter = (NotTooOldFilter,)

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -66,30 +66,34 @@ msgstr "Anzahl"
msgid "Thumbnail" msgid "Thumbnail"
msgstr "Bild" msgstr "Bild"
#: models.py:51 #: models.py:49
msgid "Owners"
msgstr "Verantwortliche"
#: models.py:59
msgid "Not too old?" msgid "Not too old?"
msgstr "Nicht zu alt?" msgstr "Nicht zu alt?"
#: models.py:54 #: models.py:62
msgid "material part" msgid "material part"
msgstr "Materialteil" msgstr "Materialteil"
#: models.py:55 #: models.py:63
msgid "material parts" msgid "material parts"
msgstr "Materialteile" msgstr "Materialteile"
#: models.py:61 #: models.py:69
msgid "owner" msgid "owner"
msgstr "Besitzer" msgstr "Besitzer"
#: models.py:62 #: models.py:70
msgid "count" msgid "count"
msgstr "Anzahl" msgstr "Anzahl"
#: models.py:69 #: models.py:77
msgid "ownership" msgid "ownership"
msgstr "Besitzer" msgstr "Besitzer"
#: models.py:70 #: models.py:78
msgid "ownerships" msgid "ownerships"
msgstr "Verantwortliche" msgstr "Verantwortliche"

@ -40,6 +40,14 @@ class MaterialPart(models.Model):
admin_thumbnail.short_description = _('Thumbnail') admin_thumbnail.short_description = _('Thumbnail')
admin_thumbnail.allow_tags = True admin_thumbnail.allow_tags = True
def ownership_overview(self):
summary = ''
for owner in self.ownership_set.all():
summary += '<p>{}: {}</p>'.format(str(owner.owner), owner.count)
return summary
ownership_overview.allow_tags = True
ownership_overview.short_description = _('Owners')
def not_too_old(self): def not_too_old(self):
"""Returns wether the part should be replaced cause of age""" """Returns wether the part should be replaced cause of age"""
buy_time = timezone.make_aware(datetime.combine(self.buy_date, buy_time = timezone.make_aware(datetime.combine(self.buy_date,

Loading…
Cancel
Save