def sync_history_context(video, subtitle_language): context = {} sync_history = SyncHistory.objects.get_sync_history_for_subtitle_language( subtitle_language) context['sync_history'] = sync_history context['can_resync'] = ( len(sync_history) > 0) and not sync_history[0]['account'].should_skip_syncing() context['current_version'] = subtitle_language.get_public_tip() synced_versions = [] for video_url in video.get_video_urls(): if not can_sync_videourl(video_url): continue try: version = (subtitle_language.syncedsubtitleversion_set. select_related('version').get( video_url=video_url)).version except ObjectDoesNotExist: version = None synced_versions.append({ 'video_url': video_url, 'version': version, 'syncable': get_sync_account(video, video_url), }) context['synced_versions'] = synced_versions return context
def setup_tab(self, request, video, language, version): self['sync_history'] = language.synchistory_set.order_by('-id').all() self['current_version'] = language.get_public_tip() synced_versions = [] for video_url in video.get_video_urls(): if not can_sync_videourl(video_url): continue try: version = (language.syncedsubtitleversion_set.select_related( 'version').get(video_url=video_url)).version except ObjectDoesNotExist: version = None synced_versions.append({ 'video_url': video_url, 'version': version, }) self['synced_versions'] = synced_versions
def setup_tab(self, request, video, language, version): self['sync_history'] = (language.synchistory_set.select_related( 'version').fetch_with_accounts()) self['current_version'] = language.get_public_tip() synced_versions = [] for video_url in video.get_video_urls(): if not can_sync_videourl(video_url): continue version = None sync_account = get_sync_account(video, video_url) synced_version_qs = ( language.syncedsubtitleversion_set.select_related('version')) for ssv in synced_version_qs: if ssv.is_for_account(sync_account): version = ssv.version break synced_versions.append({ 'video_url': video_url, 'version': version, 'syncable': sync_account is not None, }) self['synced_versions'] = synced_versions