def _get_team_video_from_search_record(search_record): if getattr(search_record, '_team_video', None): # This is ugly, but allows us to pre-fetch the teamvideos for the # search records all at once to avoid multiple DB queries. return search_record._team_video else: try: return TeamVideo.objects.get(pk=search_record.team_video_pk) except TeamVideo.DoesNotExist: from raven.contrib.django.models import client client.create_from_exception() try: return TeamVideo.objects.get(video=search_record.video_pk) except TeamVideo.DoesNotExist: from raven.contrib.django.models import client client.create_from_exception() return None
def _get_team_video_from_search_record(search_record): if getattr(search_record, '_team_video', None): # This is ugly, but allows us to pre-fetch the teamvideos for the # search records all at once to avoid multiple DB queries. return search_record._team_video else: try: return TeamVideo.objects.get(pk=search_record.team_video_pk) except TeamVideo.DoesNotExist: from raven.contrib.django.models import client client.create_from_exception() # ok, for some reason, this search record got stale. # no idea why. # so let's delete it so this can't happen again tv_search_index = site.get_index(TeamVideo) tv_search_index.backend.remove(search_record.id) logger.error("Removing %s from solr since it's stale" % search_record.id) return None
def upload_subtitles(request): output = dict(success=False) form = SubtitlesUploadForm(request.user, request.POST, request.FILES) if form.is_valid(): try: language = form.save() output['success'] = True if form._sl_created: output['msg'] = ugettext( u'Thank you for uploading. It will take a minute or so for your subtitles to appear.' ) else: output['msg'] = ugettext(u'Your changes have been saved.') output['next'] = language.get_absolute_url() transaction.commit() except AlreadyEditingException, e: output['errors'] = {"_all__": [force_unicode(e.msg)]} transaction.rollback() except Exception, e: output['errors'] = {"_all__": [force_unicode(e)]} transaction.rollback() from raven.contrib.django.models import client client.create_from_exception()
if form.is_valid(): version = form.save() output['success'] = True output['next'] = version.subtitle_language.get_absolute_url() output['msg'] = ugettext( u'Thank you for uploading. ' u'It may take a minute or so for your subtitles to appear.') else: output['errors'] = form.get_errors() except AlreadyEditingException, e: output['errors'] = {'__all__': [force_unicode(e.msg)]} except Exception, e: import traceback traceback.print_exc() from raven.contrib.django.models import client client.create_from_exception() output['errors'] = {'__all__': [force_unicode(e)]} return response(output) @login_required def upload_transcription_file(request): output = {} form = TranscriptionFileForm(request.POST, request.FILES) if form.is_valid(): output['text'] = getattr(form, 'file_text', '') else: output['errors'] = form.get_errors() return HttpResponse(u'<textarea>%s</textarea>' % json.dumps(output)) def feedback(request, hide_captcha=False):