Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Force video admin interface to avoid using cached query results.

  • Loading branch information...
commit 6c45f8e99986fb3da29082a208b5f81db84997af 1 parent 85e0633
Michael Kelly Osmose authored
Showing with 22 additions and 3 deletions.
  1. +18 −0 flicks/base/admin.py
  2. +4 −3 flicks/videos/admin.py
18 flicks/base/admin.py
View
@@ -0,0 +1,18 @@
+from django.contrib import admin
+
+from caching.base import CachingQuerySet
+
+
+class BaseModelAdmin(admin.ModelAdmin):
+ """
+ Base class to use for ModalAdmins across the site.
+
+ Handles a few common tasks, like forcing CachingQuerySets to not cache
+ their results in the admin interface.
+ """
+ def queryset(self, request):
+ """Force CachingQuerySet to not cache in the admin interface."""
+ qs = super(BaseModelAdmin, self).queryset(request)
+ if isinstance(qs, CachingQuerySet):
+ qs = qs.no_cache()
+ return qs
7 flicks/videos/admin.py
View
@@ -1,10 +1,11 @@
from django.contrib import admin
+from flicks.base.admin import BaseModelAdmin
from flicks.videos.models import Award, Video2012, Video2013
from flicks.videos.tasks import process_video
-class Video2013Admin(admin.ModelAdmin):
+class Video2013Admin(BaseModelAdmin):
list_display = ['title', 'user_full_name', 'user_email', 'created',
'vimeo_id', 'filename', 'processed', 'approved']
list_filter = ['processed', 'approved']
@@ -46,7 +47,7 @@ def process_videos(self, request, queryset):
admin.site.register(Video2013, Video2013Admin)
-class Video2012Admin(admin.ModelAdmin):
+class Video2012Admin(BaseModelAdmin):
"""Configuration for the video admin pages."""
list_display = ['title', 'user_email', 'state', 'judge_mark', 'category',
'region', 'shortlink', 'created']
@@ -55,7 +56,7 @@ class Video2012Admin(admin.ModelAdmin):
admin.site.register(Video2012, Video2012Admin)
-class AwardAdmin(admin.ModelAdmin):
+class AwardAdmin(BaseModelAdmin):
"""Configuration for the award admin pages."""
list_display = ['region', 'award_type', 'category', 'video', 'preview']
admin.site.register(Award, AwardAdmin)
Please sign in to comment.
Something went wrong with that request. Please try again.