summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2019-10-03 19:20:45 -0700
committerBryan Newbold <bnewbold@robocracy.org>2019-10-03 19:20:45 -0700
commit7e945babae47a725a80b4a9cff0c58dce534c101 (patch)
tree987756bcd0752a3ef60f90371cd20935707ccb59 /python
parent2e2bbc2ab9642675abdec6696b8862e67593323a (diff)
downloadfatcat-7e945babae47a725a80b4a9cff0c58dce534c101.tar.gz
fatcat-7e945babae47a725a80b4a9cff0c58dce534c101.zip
redirect direct entity underscore links
Diffstat (limited to 'python')
-rw-r--r--python/fatcat_web/routes.py28
-rw-r--r--python/tests/web_entity_views.py2
2 files changed, 30 insertions, 0 deletions
diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py
index 1213ce11..79b594e3 100644
--- a/python/fatcat_web/routes.py
+++ b/python/fatcat_web/routes.py
@@ -231,6 +231,10 @@ def generic_editgroup_entity_view(editgroup_id, entity_type, ident, view_templat
def container_view(ident):
return generic_entity_view('container', ident, 'container_view.html')
+@app.route('/container_<ident>', methods=['GET'])
+def container_underscore_view(ident):
+ return redirect('/container/{}'.format(ident))
+
@app.route('/container/<ident>/coverage', methods=['GET'])
def container_view_coverage(ident):
return generic_entity_view('container', ident, 'container_view_coverage.html')
@@ -260,6 +264,10 @@ def container_editgroup_view_metadata(editgroup_id, ident):
def creator_view(ident):
return generic_entity_view('creator', ident, 'creator_view.html')
+@app.route('/creator_<ident>', methods=['GET'])
+def creator_underscore_view(ident):
+ return redirect('/creator/{}'.format(ident))
+
@app.route('/creator/<ident>/metadata', methods=['GET'])
def creator_view_metadata(ident):
return generic_entity_view('creator', ident, 'entity_view_metadata.html')
@@ -285,6 +293,10 @@ def creator_editgroup_view_metadata(editgroup_id, ident):
def file_view(ident):
return generic_entity_view('file', ident, 'file_view.html')
+@app.route('/file_<ident>', methods=['GET'])
+def file_underscore_view(ident):
+ return redirect('/file/{}'.format(ident))
+
@app.route('/file/<ident>/metadata', methods=['GET'])
def file_view_metadata(ident):
return generic_entity_view('file', ident, 'entity_view_metadata.html')
@@ -310,6 +322,10 @@ def file_editgroup_view_metadata(editgroup_id, ident):
def fileset_view(ident):
return generic_entity_view('fileset', ident, 'fileset_view.html')
+@app.route('/fileset_<ident>', methods=['GET'])
+def fileset_underscore_view(ident):
+ return redirect('/fileset/{}'.format(ident))
+
@app.route('/fileset/<ident>/metadata', methods=['GET'])
def fileset_view_metadata(ident):
return generic_entity_view('fileset', ident, 'entity_view_metadata.html')
@@ -335,6 +351,10 @@ def fileset_editgroup_view_metadata(editgroup_id, ident):
def webcapture_view(ident):
return generic_entity_view('webcapture', ident, 'webcapture_view.html')
+@app.route('/webcapture_<ident>', methods=['GET'])
+def webcapture_underscore_view(ident):
+ return redirect('/webcapture/{}'.format(ident))
+
@app.route('/webcapture/<ident>/metadata', methods=['GET'])
def webcapture_view_metadata(ident):
return generic_entity_view('webcapture', ident, 'entity_view_metadata.html')
@@ -360,6 +380,10 @@ def webcapture_editgroup_view_metadata(editgroup_id, ident):
def release_view(ident):
return generic_entity_view('release', ident, 'release_view.html')
+@app.route('/release_<ident>', methods=['GET'])
+def release_underscore_view(ident):
+ return redirect('/release/{}'.format(ident))
+
@app.route('/release/<ident>/contribs', methods=['GET'])
def release_view_contribs(ident):
return generic_entity_view('release', ident, 'release_view_contribs.html')
@@ -409,6 +433,10 @@ def release_editgroup_view_metadata(editgroup_id, ident):
def work_view(ident):
return generic_entity_view('work', ident, 'work_view.html')
+@app.route('/work_<ident>', methods=['GET'])
+def work_underscore_view(ident):
+ return redirect('/work/{}'.format(ident))
+
@app.route('/work/<ident>/metadata', methods=['GET'])
def work_view_metadata(ident):
return generic_entity_view('work', ident, 'entity_view_metadata.html')
diff --git a/python/tests/web_entity_views.py b/python/tests/web_entity_views.py
index 6555eeeb..c42661cb 100644
--- a/python/tests/web_entity_views.py
+++ b/python/tests/web_entity_views.py
@@ -34,6 +34,8 @@ def test_entity_basics(app):
# good requests
rv = app.get('/{}/{}'.format(entity_type, ident))
assert rv.status_code == 200
+ rv = app.get('/{}_{}'.format(entity_type, ident))
+ assert rv.status_code == 302
rv = app.get('/{}/{}/history'.format(entity_type, ident))
assert rv.status_code == 200
rv = app.get('/{}/{}/metadata'.format(entity_type, ident))