Merge pull request #72 from Schlabonski/material-beautify

beautify material and inlines
v1-0-stable
Christian Merten 9 years ago committed by GitHub
commit cafd0d2bde

@ -10,7 +10,7 @@ from .models import Message, Attachment, MessageForm
from .mailutils import NOT_SENT, PARTLY_SENT from .mailutils import NOT_SENT, PARTLY_SENT
class AttachmentInline(admin.StackedInline): class AttachmentInline(admin.TabularInline):
model = Attachment model = Attachment
extra = 0 extra = 0
@ -52,6 +52,9 @@ class MessageAdmin(admin.ModelAdmin):
submit_message(obj, request) submit_message(obj, request)
return super(MessageAdmin, self).response_add(request, obj) return super(MessageAdmin, self).response_add(request, obj)
class Media:
css = {'all': ('admin/css/tabular_hide_original.css',)}
def submit_message(msg, request): def submit_message(msg, request):
success = msg.submit() success = msg.submit()

@ -9,7 +9,7 @@ from easy_select2 import apply_select2
# Register your models here. # Register your models here.
class OwnershipInline(admin.StackedInline): class OwnershipInline(admin.TabularInline):
""" """
This shows the ownership selection directly in the MaterialPart edit This shows the ownership selection directly in the MaterialPart edit
view view
@ -38,13 +38,17 @@ class NotTooOldFilter(SimpleListFilter):
return queryset.filter(pk__in=[x.pk for x in queryset.all() if not x.not_too_old()]) return queryset.filter(pk__in=[x.pk for x in queryset.all() if not x.not_too_old()])
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', 'lifetime', 'not_too_old', 'photo') list_display = ('name', 'description', 'quantity_real',
'ownership_overview', 'buy_date',
'lifetime', 'not_too_old', 'admin_thumbnail')
inlines = [OwnershipInline] inlines = [OwnershipInline]
list_filter = (NotTooOldFilter,) list_filter = (NotTooOldFilter,)
class Media:
css = {'all': ('admin/css/tabular_hide_original.css',)}
admin.site.register(MaterialPart, MaterialAdmin) admin.site.register(MaterialPart, MaterialAdmin)

@ -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 10:06+0000\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"
@ -18,74 +18,82 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: material/admin.py:25 #: admin.py:25
msgid "Age" msgid "Age"
msgstr "Alter" msgstr "Alter"
#: material/admin.py:30 #: admin.py:30
msgid "Not too old" msgid "Not too old"
msgstr "Nicht zu alt" msgstr "Nicht zu alt"
#: material/admin.py:31 #: admin.py:31
msgid "Too old" msgid "Too old"
msgstr "Zu alt" msgstr "Zu alt"
#: material/apps.py:7 #: apps.py:7
msgid "material" msgid "material"
msgstr "Material" msgstr "Material"
#: material/models.py:17 #: models.py:17
msgid "name" msgid "name"
msgstr "Name" msgstr "Name"
#: material/models.py:18 #: models.py:18
msgid "description" msgid "description"
msgstr "Beschreibung" msgstr "Beschreibung"
#: material/models.py:19 #: models.py:19
msgid "quantity" msgid "quantity"
msgstr "Anzahl" msgstr "Anzahl"
#: material/models.py:20 #: models.py:20
msgid "purchase date" msgid "purchase date"
msgstr "Kaufdatum" msgstr "Kaufdatum"
#: material/models.py:21 #: models.py:21
msgid "lifetime (years)" msgid "lifetime (years)"
msgstr "Lebenszeit (Jahre)" msgstr "Lebenszeit (Jahre)"
#: material/models.py:22 #: models.py:22
msgid "photo" msgid "photo"
msgstr "Bild" msgstr "Bild"
#: material/models.py:33 #: models.py:33
msgid "Quantity" msgid "Quantity"
msgstr "Anzahl" msgstr "Anzahl"
#: material/models.py:43 #: models.py:40
msgid "Thumbnail"
msgstr "Bild"
#: 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?"
#: material/models.py:46 #: models.py:62
msgid "material part" msgid "material part"
msgstr "Materialteil" msgstr "Materialteil"
#: material/models.py:47 #: models.py:63
msgid "material parts" msgid "material parts"
msgstr "Materialteile" msgstr "Materialteile"
#: material/models.py:53 #: models.py:69
msgid "owner" msgid "owner"
msgstr "Besitzer" msgstr "Besitzer"
#: material/models.py:54 #: models.py:70
msgid "count" msgid "count"
msgstr "Anzahl" msgstr "Anzahl"
#: material/models.py:61 #: models.py:77
msgid "ownership" msgid "ownership"
msgstr "Besitzer" msgstr "Besitzer"
#: material/models.py:62 #: models.py:78
msgid "ownerships" msgid "ownerships"
msgstr "Verantwortliche" msgstr "Verantwortliche"

@ -32,6 +32,22 @@ class MaterialPart(models.Model):
quantity_real.admin_order_field = 'quantity' quantity_real.admin_order_field = 'quantity'
quantity_real.short_description = _('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 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,

@ -71,7 +71,7 @@ class MemberListAdminForm(forms.ModelForm):
#self.fields['add_member'].queryset = Member.objects.filter(prename__startswith='F') #self.fields['add_member'].queryset = Member.objects.filter(prename__startswith='F')
class MemberOnListInline(admin.StackedInline): class MemberOnListInline(admin.TabularInline):
model = MemberOnList model = MemberOnList
extra = 0 extra = 0
formfield_overrides = { formfield_overrides = {
@ -92,6 +92,9 @@ class MemberListAdmin(admin.ModelAdmin):
ForeignKey: {'widget': apply_select2(forms.Select)} ForeignKey: {'widget': apply_select2(forms.Select)}
} }
class Media:
css = {'all': ('admin/css/tabular_hide_original.css',)}
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(MemberListAdmin, self).__init__(*args, **kwargs) super(MemberListAdmin, self).__init__(*args, **kwargs)
@ -311,7 +314,7 @@ class KlettertreffAttendeeInlineForm(forms.ModelForm):
self.fields['member'].queryset = Member.objects.filter(group__name='J1') self.fields['member'].queryset = Member.objects.filter(group__name='J1')
""" """
class KlettertreffAttendeeInline(admin.StackedInline): class KlettertreffAttendeeInline(admin.TabularInline):
model = KlettertreffAttendee model = KlettertreffAttendee
form = KlettertreffAttendeeInlineForm form = KlettertreffAttendeeInlineForm
extra = 0 extra = 0
@ -351,6 +354,9 @@ class KlettertreffAdmin(admin.ModelAdmin):
ForeignKey: {'widget': apply_select2(forms.Select)} ForeignKey: {'widget': apply_select2(forms.Select)}
} }
class Media:
css = {'all': ('admin/css/tabular_hide_original.css',)}
admin.site.register(Member, MemberAdmin) admin.site.register(Member, MemberAdmin)
admin.site.register(Group, GroupAdmin) admin.site.register(Group, GroupAdmin)

Loading…
Cancel
Save