X-Git-Url: https://git.mdrn.pl/django-migdal.git/blobdiff_plain/2779a04736253bc7a56ac891cd36d0bfce990ad1..02292261ebd2751d8d519fffadfbc1ca9bf43cba:/migdal/admin.py diff --git a/migdal/admin.py b/migdal/admin.py index f9974be..ed829e6 100644 --- a/migdal/admin.py +++ b/migdal/admin.py @@ -5,7 +5,7 @@ from django.conf import settings from django.contrib import admin from django.utils.translation import ugettext_lazy as _ -from migdal.models import Entry, Attachment +from migdal.models import Entry, Attachment, Photo from migdal import app_settings from fnpdjango.utils.models import filtered_model from fnpdjango.utils.models.translation import translated_fields @@ -16,6 +16,11 @@ class AttachmentInline(admin.TabularInline): readonly_fields = ['url'] +class PhotoInline(admin.TabularInline): + model = Photo + readonly_fields = ['url'] + + def filtered_entry_admin(typ): class EntryAdmin(admin.ModelAdmin): def get_queryset(self, request): @@ -37,8 +42,9 @@ def filtered_entry_admin(typ): return field date_hierarchy = 'date' - readonly_fields = ('date', 'changed_at', 'first_published_at') + \ - translated_fields(('published_at',)) + readonly_fields = ('date', 'changed_at') + translated_fields(('published_at',)) + if app_settings.PUBLISH_DATE_EDITABLE: + readonly_fields += ('first_published_at',) _promo_if_necessary = ('promo',) if typ.promotable else () fieldsets = ( @@ -55,6 +61,8 @@ def filtered_entry_admin(typ): 'slug_%s' % lc, 'lead_%s' % lc, 'body_%s' % lc, + 'place_%s' % lc, + 'time_%s' % lc, )}) for lc, ln in app_settings.OBLIGATORY_LANGUAGES ) + tuple( @@ -65,6 +73,8 @@ def filtered_entry_admin(typ): 'slug_%s' % lc, 'lead_%s' % lc, 'body_%s' % lc, + 'place_%s' % lc, + 'time_%s' % lc, )}) for lc, ln in app_settings.OPTIONAL_LANGUAGES ) @@ -87,7 +97,7 @@ def filtered_entry_admin(typ): list_filter = _promo_if_necessary + \ translated_fields(('published',)) + \ translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES) - inlines = (AttachmentInline,) + inlines = (PhotoInline, AttachmentInline) search_fields = ('title_pl', 'title_en') return EntryAdmin