summaryrefslogtreecommitdiffstats
path: root/python/fatcat_web/routes.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/fatcat_web/routes.py')
-rw-r--r--python/fatcat_web/routes.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index 3479a937..f7f10f44 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -13,6 +13,7 @@ from fatcat_web import app, api, auth_api, priv_api
from fatcat_web.auth import handle_token_login, handle_logout, load_user, handle_ia_xauth
from fatcat_web.cors import crossdomain
from fatcat_web.search import *
+from fatcat_web.hacks import strip_extlink_xml, wayback_suffix
### Views ###################################################################
@@ -231,6 +232,8 @@ def webcapture_view(ident):
entity.releases.append(api.get_release(r))
except ApiException as ae:
abort(ae.status)
+ entity.wayback_suffix = wayback_suffix(entity)
+ print("SUFFIX: {}".format(entity.wayback_suffix))
return render_template('webcapture_view.html', webcapture=entity)
@app.route('/release/lookup', methods=['GET'])
@@ -266,8 +269,6 @@ def release_history(ident):
def release_view(ident):
try:
entity = api.get_release(ident, expand="container,files,filesets,webcaptures")
- container = entity.container
- filesets = entity.filesets
except ApiException as ae:
abort(ae.status)
if entity.state == "redirect":
@@ -278,13 +279,23 @@ def release_view(ident):
entity.container.es = container_to_elasticsearch(entity.container, force_bool=False)
if entity.state == "active":
entity.es = release_to_elasticsearch(entity, force_bool=False)
- for fs in filesets:
+ for fs in entity.filesets:
fs.total_size = sum([f.size for f in fs.manifest])
- entity.filesets = filesets
+ for wc in entity.webcaptures:
+ wc.wayback_suffix = wayback_suffix(wc)
+ for ref in entity.refs:
+ # this is a UI hack to get rid of XML crud in unstructured refs like:
+ # LOCKSS (2014) Available: <ext-link
+ # xmlns:xlink="http://www.w3.org/1999/xlink" ext-link-type="uri"
+ # xlink:href="http://lockss.org/"
+ # xlink:type="simple">http://lockss.org/</ext-link>. Accessed: 2014
+ # November 1.
+ if ref.extra and ref.extra.get('unstructured'):
+ ref.extra['unstructured'] = strip_extlink_xml(ref.extra['unstructured'])
authors = [c for c in entity.contribs if c.role in ('author', None)]
authors = sorted(authors, key=lambda c: c.index or 99999999)
return render_template('release_view.html', release=entity,
- authors=authors, container=container)
+ authors=authors, container=entity.container)
@app.route('/work/<ident>/history', methods=['GET'])
def work_history(ident):
@@ -382,6 +393,9 @@ def editgroup_accept(ident):
except ApiException as ae:
app.log.info(ae)
abort(ae.status)
+ # clear active_editgroup_id cookie; this doesn't cover all cases
+ if eg.editgroup_id == session.get('active_editgroup_id'):
+ session.pop('active_editgroup_id')
return redirect('/editgroup/{}'.format(ident))
@app.route('/editgroup/<ident>/unsubmit', methods=['POST'])
@@ -650,7 +664,11 @@ def logout():
@app.route('/auth/account')
@login_required
def auth_account():
- editor = api.get_editor(session['editor']['editor_id'])
+ # auth check on account page
+ user_api = auth_api(session['api_token'])
+ resp = user_api.auth_check()
+ assert(resp.success)
+ editor = user_api.get_editor(session['editor']['editor_id'])
session['editor'] = editor.to_dict()
load_user(editor.editor_id)
return render_template('auth_account.html')