From 7e945babae47a725a80b4a9cff0c58dce534c101 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 3 Oct 2019 19:20:45 -0700 Subject: redirect direct entity underscore links --- python/fatcat_web/routes.py | 28 ++++++++++++++++++++++++++++ python/tests/web_entity_views.py | 2 ++ 2 files changed, 30 insertions(+) (limited to 'python') 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_', methods=['GET']) +def container_underscore_view(ident): + return redirect('/container/{}'.format(ident)) + @app.route('/container//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_', methods=['GET']) +def creator_underscore_view(ident): + return redirect('/creator/{}'.format(ident)) + @app.route('/creator//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_', methods=['GET']) +def file_underscore_view(ident): + return redirect('/file/{}'.format(ident)) + @app.route('/file//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_', methods=['GET']) +def fileset_underscore_view(ident): + return redirect('/fileset/{}'.format(ident)) + @app.route('/fileset//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_', methods=['GET']) +def webcapture_underscore_view(ident): + return redirect('/webcapture/{}'.format(ident)) + @app.route('/webcapture//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_', methods=['GET']) +def release_underscore_view(ident): + return redirect('/release/{}'.format(ident)) + @app.route('/release//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_', methods=['GET']) +def work_underscore_view(ident): + return redirect('/work/{}'.format(ident)) + @app.route('/work//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)) -- cgit v1.2.3