aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-05-20 19:57:02 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-05-20 19:57:02 -0700
commit3ebea73882a35ea1e892899d959efaed0264ec66 (patch)
tree015d814bd6db4c8c41e81ea7a0ec91481267d4ae
parent7815c6739e4ae730c7fe4589e8aa15b2b0f1033d (diff)
downloadfatcat-3ebea73882a35ea1e892899d959efaed0264ec66.tar.gz
fatcat-3ebea73882a35ea1e892899d959efaed0264ec66.zip
simplify file/fileset/webcapture views with release expansion
-rw-r--r--python/fatcat_web/routes.py28
1 files changed, 4 insertions, 24 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index a61c7c6d..6c520344 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -145,20 +145,13 @@ def file_lookup():
@app.route('/file/<ident>', methods=['GET'])
def file_view(ident):
try:
- entity = api.get_file(ident)
+ entity = api.get_file(ident, expand="releases")
except ApiException as ae:
abort(ae.status)
if entity.state == "redirect":
return redirect('/file/{}'.format(entity.redirect))
elif entity.state == "deleted":
return render_template('deleted_entity.html', entity=entity, entity_type="file")
- else:
- try:
- entity.releases = []
- for r in entity.release_ids:
- entity.releases.append(api.get_release(r))
- except ApiException as ae:
- abort(ae.status)
return render_template('file_view.html', file=entity)
@app.route('/fileset/<ident>/history', methods=['GET'])
@@ -181,7 +174,7 @@ def fileset_lookup():
@app.route('/fileset/<ident>', methods=['GET'])
def fileset_view(ident):
try:
- entity = api.get_fileset(ident)
+ entity = api.get_fileset(ident, expand="releases")
except ApiException as ae:
abort(ae.status)
if entity.state == "redirect":
@@ -189,12 +182,6 @@ def fileset_view(ident):
elif entity.state == "deleted":
return render_template('deleted_entity.html', entity=entity, entity_type="fileset")
else:
- try:
- entity.releases = []
- for r in entity.release_ids:
- entity.releases.append(api.get_release(r))
- except ApiException as ae:
- abort(ae.status)
entity.total_size = sum([f.size for f in entity.manifest])
return render_template('fileset_view.html', fileset=entity)
@@ -218,22 +205,15 @@ def webcapture_lookup():
@app.route('/webcapture/<ident>', methods=['GET'])
def webcapture_view(ident):
try:
- entity = api.get_webcapture(ident)
+ entity = api.get_webcapture(ident, expand="releases")
except ApiException as ae:
abort(ae.status)
if entity.state == "redirect":
return redirect('/webcapture/{}'.format(entity.redirect))
elif entity.state == "deleted":
return render_template('deleted_entity.html', entity=entity, entity_type="webcapture")
- else:
- try:
- entity.releases = []
- for r in entity.release_ids:
- 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))
+ #print("SUFFIX: {}".format(entity.wayback_suffix))
return render_template('webcapture_view.html', webcapture=entity)
@app.route('/release/lookup', methods=['GET'])