Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix Bug 841396: Add admin action to process videos.

Also changes the vimeo task retry delay to 5 minutes.
  • Loading branch information...
commit 065386bd4c2e438f356dec0c241ea8dc16c2fa77 1 parent 5506326
@Osmose Osmose authored
Showing with 19 additions and 3 deletions.
  1. +18 −2 flicks/videos/admin.py
  2. +1 −1  flicks/videos/decorators.py
View
20 flicks/videos/admin.py
@@ -1,17 +1,18 @@
from django.contrib import admin
from flicks.videos.models import Award, Video2012, Video2013
+from flicks.videos.tasks import process_video
class Video2013Admin(admin.ModelAdmin):
list_display = ['title', 'user_full_name', 'user_email', 'created',
'vimeo_id', 'filename', 'processed', 'approved']
list_filter = ['processed', 'approved']
+
search_fields = ['title', 'description', 'user__userprofile__full_name',
'user__email']
- change_form_template = 'admin/video2013_change_form.html'
-
readonly_fields = ['filename', 'processed', 'user_notified', 'created']
+
fieldsets = (
(None, {
'fields': ('title', 'user', 'created', 'vimeo_id', 'filename',
@@ -22,11 +23,26 @@ class Video2013Admin(admin.ModelAdmin):
})
)
+ actions = ['process_videos']
+ change_form_template = 'admin/video2013_change_form.html'
+
def user_full_name(self, instance):
return instance.user.profile.full_name if instance.user.profile else ''
def user_email(self, instance):
return instance.user.email
+
+ def process_videos(self, request, queryset):
+ """Synchronously run the video processing task on the selected videos."""
+ for video in queryset:
+ process_video(video.id)
+
+ count = len(queryset)
+ count_string = '1 video' if count == 1 else '{0} videos'.format(count)
+ self.message_user(request,
+ '{0} processed successfully.'.format(count_string))
+ process_videos.short_description = 'Manually run video processing'
+
admin.site.register(Video2013, Video2013Admin)
View
2  flicks/videos/decorators.py
@@ -19,7 +19,7 @@ def vimeo_task(func):
Mark a function as a celery task and automatically retry if any
VimeoServiceErrors are raised.
"""
- @task(default_retry_delay=30 * 60) # Retry once every 30 minutes.
+ @task(default_retry_delay=5 * 60) # Retry once every 5 minutes.
@wraps(func)
def wrapped(*args, **kwargs):
from flicks.videos import vimeo
Please sign in to comment.
Something went wrong with that request. Please try again.