Commits

Anonymous committed ad8af02

more improvemets to the admin/ list_editable/ date hierarchy

  • Participants
  • Parent commits 9c7a217
  • Branches cms-trunk

Comments (0)

Files changed (1)

File cmsplugin_photologue/admin.py

 class PhotoImprovedAdmin(PhotoAdmin):
 
     form = PhotoForm
+    
+    date_hierarchy = 'date_taken'
+    
+    list_display = ('__unicode__', 'title', 'date_added', 'is_public', 'tags', 'view_count', 'admin_thumbnail')
+    list_editable = ['title', 'is_public']
 
-    def save_model(self, request, obj, form, change):  
-        obj.galleries.clear()
-        for gallery in form.cleaned_data['galleries']:
-            obj.galleries.add(gallery)
+    def save_model(self, request, obj, form, change):
+        galleries = form.cleaned_data.get('galleries', [])
+        if galleries:
+            obj.galleries.clear()
+            for gallery in galleries:
+                obj.galleries.add(gallery)
         obj.save()
 
     def get_form(self, request, obj=None, **kwargs):