def upload_subtitles(request): output = dict(success=False) form = SubtitlesUploadForm(request.user, request.POST, request.FILES) if form.is_valid(): form.save() output['success'] = True else: output['errors'] = form.get_errors() return HttpResponse(json.dumps(output), "text/javascript")
def upload_subtitles(request): output = dict(success=False) form = SubtitlesUploadForm(request.user, request.POST, request.FILES) if form.is_valid(): language = form.save() output['success'] = True output['next'] = language.get_absolute_url() else: output['errors'] = form.get_errors() return HttpResponse(json.dumps(output), "text/javascript")
def upload_subtitles(request): output = dict(success=False) form = SubtitlesUploadForm(request.user, request.POST, request.FILES) if form.is_valid(): language = form.save() output["success"] = True output["next"] = language.get_absolute_url() else: output["errors"] = form.get_errors() return HttpResponse(json.dumps(output), "text/javascript")
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 output['next'] = language.get_absolute_url() transaction.commit() except AlreadyEditingException, e: output['errors'] = {"_all__":[force_unicode(e.msg)]} transaction.rollback()
def _import_srt(self, video, videosrt_url): h = httplib2.Http() resp, content = h.request(videosrt_url, "GET") if resp.status == 200: data = {'video': video.id, 'language': 'en', 'video_language': 'en', 'is_complete': True } file_data = {'subtitles': SimpleUploadedFile('subs.srt', content)} form = SubtitlesUploadForm( CustomUser.get_youtube_anonymous(), data, file_data) if form.is_valid(): form.save() else: print('url {0} did not return valid srt data'.format(videosrt_url))
def _import_srt(self, video, videosrt_url): h = httplib2.Http() resp, content = h.request(videosrt_url, "GET") if resp.status == 200: data = { 'video': video.id, 'language': 'en', 'video_language': 'en', 'is_complete': True } file_data = {'subtitles': SimpleUploadedFile('subs.srt', content)} form = SubtitlesUploadForm(CustomUser.get_youtube_anonymous(), data, file_data) if form.is_valid(): form.save() else: print('url {0} did not return valid srt data'.format( videosrt_url))
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: #trying find out one error on dev-server. hope this should help transaction.rollback() raise e
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: #trying find out one error on dev-server. hope this should help transaction.rollback() raise e
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()