def ingest_mets_xml(request):
if request.method == 'POST':
try:
#if ingest_mets_xml_file_form.is_valid(): # TODO Check something for better error messages? And validate the file. Note: Django allows form submission, even if no file has been selected.
t_ingest_mets_xml(request.POST.get('collection'), request.FILES['mets_file'])
messages.info(request, 'File is being uploaded.')# TODO i18n,
return HttpResponse(json.dumps({'RESET': 'true', 'MESSAGE': render_to_string('library/message_modal.html', request=request)}), content_type='text/plain')
except:
messages.error(request, 'Error!')# TODO i18n,
return HttpResponse(json.dumps({'RESET': 'false', 'MESSAGE': render_to_string('library/message_modal.html', request=request)}), content_type='text/plain')
else:
ingest_mets_xml_file_form = MetsFileForm()
collections = t_collections(request)
if isinstance(collections,HttpResponse):
return collections
return render(request, 'library/ingest_mets_xml.html', {'ingest_mets_xml_form': ingest_mets_xml_file_form, 'collections': collections})
评论列表
文章目录