option to make publish date editable
[django-migdal.git] / migdal / admin.py
index 0df9352..a03d16c 100644 (file)
@@ -18,7 +18,7 @@ class AttachmentInline(admin.TabularInline):
 
 def filtered_entry_admin(typ):
     class EntryAdmin(admin.ModelAdmin):
-        def queryset(self, request):
+        def get_queryset(self, request):
             return self.model.objects.filter(type=typ.db)
 
         def has_add_permission(self, request):
@@ -37,14 +37,15 @@ 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 = (
             (None, {
                 'fields': _promo_if_necessary + (
-                    'in_stream', 'author', 'author_email', 'image',
+                    'in_stream', 'author', 'author_email', 'canonical_url', 'image',
                     'date', 'first_published_at', 'changed_at')
                 }),
         ) + tuple(
@@ -78,16 +79,15 @@ def filtered_entry_admin(typ):
                 for lang_code, lang_name in settings.LANGUAGES
             ]) 
 
-        list_display = translated_fields(('title',),
-                            app_settings.OBLIGATORY_LANGUAGES) + \
-                ('date', 'author') + \
-                _promo_if_necessary + \
-                ('in_stream', 'first_published_at',) + \
-                translated_fields(('published_at',)) + \
-                translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
+        list_display = translated_fields(('title',), app_settings.OBLIGATORY_LANGUAGES) + \
+            ('date', 'author') + \
+            _promo_if_necessary + \
+            ('in_stream', 'first_published_at',) + \
+            translated_fields(('published_at',)) + \
+            translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
         list_filter = _promo_if_necessary + \
-                translated_fields(('published',)) + \
-                translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
+            translated_fields(('published',)) + \
+            translated_fields(('needed',), app_settings.OPTIONAL_LANGUAGES)
         inlines = (AttachmentInline,)
         search_fields = ('title_pl', 'title_en')
     return EntryAdmin