aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web
diff options
context:
space:
mode:
Diffstat (limited to 'python/fatcat_web')
-rw-r--r--python/fatcat_web/routes.py20
-rw-r--r--python/fatcat_web/templates/deleted_entity.html43
2 files changed, 63 insertions, 0 deletions
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/<ident>/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/<ident>/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 %}
+
+<div class="ui stackable mobile reversed grid centered">
+<div class="one wide column"></div>
+<div class="fifteen wide column">
+ <h1 class="ui header">Deleted Entity
+ <div class="sub header"><code>{{ entity_type }}{{ entity.ident }}</code></div></h1>
+</div>
+</div>
+
+<div class="ui stackable mobile reversed grid centered">
+<div class="one wide column"></div>
+<div class="ten wide column" style="font-size: 16px;">
+
+<p>There used to be an entity here, but is has been deleted!
+
+<p>You can view history or revert the change using links to the right.
+
+<br>
+
+</div>
+<div class="five wide column">
+<div class="ui segment top attached">
+
+<b>Entity Type:</b> {{ entity_type }}
+</div><div class="ui segment attached">
+
+<b>Fatcat Bits</b>
+<p>State is "{{ entity.state }}". Revision:
+<br><small><code>{{ entity.revision }}</code></small>
+<br><a href="https://api.{{ config.FATCAT_DOMAIN }}/v0/{{ entity_type }}/{{ entity.ident }}">As JSON object via API</a>
+
+</div>
+<div class="two ui buttons bottom attached">
+ <a href="/entity/{{ entity.ident }}/edit" class="ui blue button">Edit Metadata</a>
+ <a href="/entity/{{ entity.ident }}/history" class="ui button">View History</a>
+</div>
+
+</div>
+</div>
+
+{% endblock %}