From 80f329e733118afdfba15ab389694f445b1c2f48 Mon Sep 17 00:00:00 2001 From: Emanuel Dima Date: Wed, 9 Apr 2014 12:07:37 +0200 Subject: [PATCH] fixed #235: auto refreshing new record page --- invenio/lib/record_blueprint.py | 3 +-- simplestore/etc/static/js/simplestore-deposit.js | 7 ++----- ...estore-finalize.html => record_waitforit.html} | 15 ++++----------- simplestore/lib/simplestore_deposit_handler.py | 4 ++-- 4 files changed, 9 insertions(+), 20 deletions(-) rename simplestore/etc/templates/{simplestore-finalize.html => record_waitforit.html} (56%) diff --git a/invenio/lib/record_blueprint.py b/invenio/lib/record_blueprint.py index 49c74c668c..2a9227f841 100644 --- a/invenio/lib/record_blueprint.py +++ b/invenio/lib/record_blueprint.py @@ -84,8 +84,7 @@ def decorated(recid, *args, **kwargs): return redirect(url_for('webaccount.login', **url_args)) elif auth_code: if check_fresh_record(current_user, recid): - flash(auth_msg, 'Please wait, your record is being processed') - abort(apache.HTTP_NOT_FOUND) + return render_template('record_waitforit.html', recid=recid) else: flash(auth_msg, 'error') abort(apache.HTTP_UNAUTHORIZED) diff --git a/simplestore/etc/static/js/simplestore-deposit.js b/simplestore/etc/static/js/simplestore-deposit.js index 62c8f3b230..784cb86152 100755 --- a/simplestore/etc/static/js/simplestore-deposit.js +++ b/simplestore/etc/static/js/simplestore-deposit.js @@ -31,11 +31,8 @@ $(document).ready(function() { $.post("addmeta/" + $('#sub_id').val(), $("#metaform_form").serialize(), function(data) { if (data.valid) { - //Load new page with success message - var newDoc = document.open("text/html", "replace"); - newDoc.write(data.html); - newDoc.close(); - + // redirect to new url location, with history + window.location.href = data.newurl; } else { //Just replace metadata form with errors $('#meta-fields').html(data.html); diff --git a/simplestore/etc/templates/simplestore-finalize.html b/simplestore/etc/templates/record_waitforit.html similarity index 56% rename from simplestore/etc/templates/simplestore-finalize.html rename to simplestore/etc/templates/record_waitforit.html index f8da31e3ba..43c071bce6 100755 --- a/simplestore/etc/templates/simplestore-finalize.html +++ b/simplestore/etc/templates/record_waitforit.html @@ -1,6 +1,7 @@ {% extends "page.html" %} {% block header %} {{ super() }} + {% css 'css/simplestore-style.css', '50-simplestore' %} {% endblock %} @@ -9,15 +10,10 @@ + {% endblock %} diff --git a/simplestore/lib/simplestore_deposit_handler.py b/simplestore/lib/simplestore_deposit_handler.py index 60753f5993..d930c18958 100644 --- a/simplestore/lib/simplestore_deposit_handler.py +++ b/simplestore/lib/simplestore_deposit_handler.py @@ -112,8 +112,8 @@ def addmeta(request, sub_id): # all usual tasks have priority 0; we want the bibuploads to run first task_low_level_submission('bibupload', 'webdeposit', '--priority', '1', '-r', tmp_file) return jsonify(valid=True, - html=render_template('simplestore-finalize.html', - recid=recid, marc=marc)) + newurl=url_for("record.metadata", recid=recid), + html=render_template('record_waitforit.html', recid=recid, marc=marc)) current_app.logger.error("returning form addmeta") return jsonify(valid=False,