From c350cb5eddf369a2ed002401e756cf91de5a04ff Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 21 Dec 2018 16:36:48 -0800 Subject: start handling redirects and deletions in webface --- python/fatcat_web/routes.py | 20 ++++++++++++ python/fatcat_web/templates/deleted_entity.html | 43 +++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 python/fatcat_web/templates/deleted_entity.html (limited to 'python') diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 0150fca5..0a1ea2c6 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -80,6 +80,10 @@ def container_view(ident): entity = api.get_container(ident) except ApiException as ae: abort(ae.status) + if entity.state == "redirect": + return redirect('/container/{}'.format(entity.redirect)) + if entity.state == "deleted": + return render_template('deleted_entity.html', entity=entity) return render_template('container_view.html', container=entity) @app.route('/creator//history', methods=['GET']) @@ -124,6 +128,10 @@ def creator_view(ident): releases = api.get_creator_releases(ident) except ApiException as ae: abort(ae.status) + if entity.state == "redirect": + return redirect('/creator/{}'.format(entity.redirect)) + if entity.state == "deleted": + return render_template('deleted_entity.html', entity=entity) return render_template('creator_view.html', creator=entity, releases=releases) @app.route('/file//history', methods=['GET']) @@ -167,6 +175,10 @@ def file_view(ident): entity = api.get_file(ident) except ApiException as ae: abort(ae.status) + if entity.state == "redirect": + return redirect('/file/{}'.format(entity.redirect)) + if entity.state == "deleted": + return render_template('deleted_entity.html', entity=entity) return render_template('file_view.html', file=entity) @app.route('/release/lookup', methods=['GET']) @@ -229,6 +241,10 @@ def release_view(ident): container = api.get_container(entity.container_id) except ApiException as ae: abort(ae.status) + if entity.state == "redirect": + return redirect('/release/{}'.format(entity.redirect)) + if entity.state == "deleted": + return render_template('deleted_entity.html', entity=entity) authors = [c for c in entity.contribs if c.role in ('author', None)] authors = sorted(authors, key=lambda c: c.index) for fe in files: @@ -273,6 +289,10 @@ def work_view(ident): releases = api.get_work_releases(ident) except ApiException as ae: abort(ae.status) + if entity.state == "redirect": + return redirect('/work/{}'.format(entity.redirect)) + if entity.state == "deleted": + return render_template('deleted_entity.html', entity=entity) return render_template('work_view.html', work=entity, releases=releases) @app.route('/editgroup/current', methods=['GET']) diff --git a/python/fatcat_web/templates/deleted_entity.html b/python/fatcat_web/templates/deleted_entity.html new file mode 100644 index 00000000..af25da54 --- /dev/null +++ b/python/fatcat_web/templates/deleted_entity.html @@ -0,0 +1,43 @@ +{% extends "base.html" %} +{% block fullbody %} + +
+
+
+

Deleted Entity +
{{ entity_type }}{{ entity.ident }}

+
+
+ +
+
+
+ +

There used to be an entity here, but is has been deleted! + +

You can view history or revert the change using links to the right. + +
+ +

+
+
+ +Entity Type: {{ entity_type }} +
+ +Fatcat Bits +

State is "{{ entity.state }}". Revision: +
{{ entity.revision }} +
As JSON object via API + +

+ + +
+
+ +{% endblock %} -- cgit v1.2.3