def resync(request, video_url_id, language_code): video_url = get_object_or_404(VideoUrl, id=video_url_id) video = video_url.video if not permissions.can_user_resync(video, request.user): return redirect_to_login(request.build_absolute_uri()) language = video.subtitle_language(language_code) if request.method == 'POST': logger.info("resyncing subtitles: %s (%s)", video, video_url) _resync_video(video, video_url, language) redirect_url = reverse('videos:translation_history', kwargs={ 'video_id': video.video_id, 'lang': language_code, 'lang_id': language.id }) return HttpResponseRedirect(redirect_url + '?tab=sync-history')
def language_subtitles(request, video, lang, lang_id, version_id=None): tab = request.GET.get('tab') if tab == 'revisions': ContextClass = LanguagePageContextRevisions elif tab == 'comments': ContextClass = LanguagePageContextComments elif tab == 'sync-history': if not permissions.can_user_resync(video, request.user): return redirect_to_login(request.build_absolute_uri()) ContextClass = LanguagePageContextSyncHistory else: # force tab to be subtitles if it doesn't match either of the other # tabs tab = 'subtitles' ContextClass = LanguagePageContextSubtitles template_name = 'videos/language-%s.html' % tab context = ContextClass(request, video, lang, lang_id, version_id) context['tab'] = tab if context['create_subtitles_form'].is_valid(): return context['create_subtitles_form'].handle_post() return render(request, template_name, context)
def can_user_resync(video, user): return permissions.can_user_resync(video, user)