def upload_dictionary(request, project, lang): prj = get_project(request, project) if not can_upload_dictionary(request.user, prj): raise PermissionDenied() lang = get_object_or_404(Language, code=lang) form = DictUploadForm(request.POST, request.FILES) if form.is_valid(): try: count = Dictionary.objects.upload(request, prj, lang, request.FILES['file'], form.cleaned_data['method']) import_message( request, count, _('No words to import found in file.'), ungettext('Imported %d word from the uploaded file.', 'Imported %d words from the uploaded file.', count)) except Exception as error: report_error(error, sys.exc_info(), request) messages.error(request, _('File upload has failed: %s') % force_text(error)) else: messages.error(request, _('Failed to process form!')) return redirect('show_dictionary', project=prj.slug, lang=lang.code)
def upload_dictionary(request, project, lang): prj = get_project(request, project) if not can_upload_dictionary(request.user, prj): raise PermissionDenied() lang = get_object_or_404(Language, code=lang) form = DictUploadForm(request.POST, request.FILES) if form.is_valid(): try: count = Dictionary.objects.upload( request, prj, lang, request.FILES['file'], form.cleaned_data['method'] ) import_message( request, count, _('No words to import found in file.'), ungettext( 'Imported %d word from the uploaded file.', 'Imported %d words from the uploaded file.', count ) ) except Exception as error: report_error(error, sys.exc_info(), request) messages.error( request, _('File upload has failed: %s') % force_text(error) ) else: messages.error(request, _('Failed to process form!')) return redirect( 'show_dictionary', project=prj.slug, lang=lang.code )