aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-07-20 15:02:55 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-07-20 15:02:55 -0700
commit677798a0b4617712e5ccc28a9ea89f9ca1ec3afa (patch)
treed35863174e8924785190e57b2b961bfa1942e1be
parentb4eb110bd880f78c5da578fe897ae97d4c734984 (diff)
downloadfatcat-677798a0b4617712e5ccc28a9ea89f9ca1ec3afa.tar.gz
fatcat-677798a0b4617712e5ccc28a9ea89f9ca1ec3afa.zip
python base32 idents
-rw-r--r--python/fatcat/routes.py132
-rw-r--r--python/fatcat/templates/home.html20
-rw-r--r--python/tests/routes.py31
3 files changed, 95 insertions, 88 deletions
diff --git a/python/fatcat/routes.py b/python/fatcat/routes.py
index b23dc9d4..c92f6493 100644
--- a/python/fatcat/routes.py
+++ b/python/fatcat/routes.py
@@ -10,19 +10,11 @@ from fatcat.search import do_search
### Views ###################################################################
-@app.route('/container/<uuid:ident>', methods=['GET'])
-def container_view(ident):
- try:
- entity = api.get_container(str(ident))
- except ApiException as ae:
- abort(ae.status)
- return render_template('container_view.html', container=entity)
-
-@app.route('/container/<uuid:ident>/history', methods=['GET'])
+@app.route('/container/<ident>/history', methods=['GET'])
def container_history(ident):
try:
- entity = api.get_container(str(ident))
- history = api.get_container_history(str(ident))
+ entity = api.get_container(ident)
+ history = api.get_container_history(ident)
except ApiException as ae:
abort(ae.status)
print(history)
@@ -32,15 +24,15 @@ def container_history(ident):
entity=entity,
history=history)
-@app.route('/container/<uuid:ident>/edit', methods=['GET'])
+@app.route('/container/<ident>/edit', methods=['GET'])
def container_edit_view(ident):
try:
- entity = api.get_container(str(ident))
+ entity = api.get_container(ident)
except ApiException as ae:
abort(ae.status)
return render_template('entity_edit.html')
-#@app.route('/container/<uuid:ident>/edit', methods=['POST'])
+#@app.route('/container/<ident>/edit', methods=['POST'])
#def container_edit(ident):
# raise NotImplemented()
# params = dict()
@@ -76,20 +68,19 @@ def container_lookup():
abort(ae.status)
return redirect('/container/{}'.format(resp.ident))
-@app.route('/creator/<uuid:ident>', methods=['GET'])
-def creator_view(ident):
+@app.route('/container/<ident>', methods=['GET'])
+def container_view(ident):
try:
- entity = api.get_creator(str(ident))
- releases = api.get_creator_releases(str(ident))
+ entity = api.get_container(ident)
except ApiException as ae:
abort(ae.status)
- return render_template('creator_view.html', creator=entity, releases=releases)
+ return render_template('container_view.html', container=entity)
-@app.route('/creator/<uuid:ident>/history', methods=['GET'])
+@app.route('/creator/<ident>/history', methods=['GET'])
def creator_history(ident):
try:
- entity = api.get_creator(str(ident))
- history = api.get_creator_history(str(ident))
+ entity = api.get_creator(ident)
+ history = api.get_creator_history(ident)
except ApiException as ae:
abort(ae.status)
return render_template('entity_history.html',
@@ -98,10 +89,10 @@ def creator_history(ident):
entity=entity,
history=history)
-@app.route('/creator/<uuid:ident>/edit', methods=['GET'])
+@app.route('/creator/<ident>/edit', methods=['GET'])
def creator_edit_view(ident):
try:
- entity = api.get_creator(str(ident))
+ entity = api.get_creator(ident)
except ApiException as ae:
abort(ae.status)
return render_template('entity_edit.html')
@@ -117,19 +108,20 @@ def creator_lookup():
abort(ae.status)
return redirect('/creator/{}'.format(resp.ident))
-@app.route('/file/<uuid:ident>', methods=['GET'])
-def file_view(ident):
+@app.route('/creator/<ident>', methods=['GET'])
+def creator_view(ident):
try:
- entity = api.get_file(str(ident))
+ entity = api.get_creator(ident)
+ releases = api.get_creator_releases(ident)
except ApiException as ae:
abort(ae.status)
- return render_template('file_view.html', file=entity)
+ return render_template('creator_view.html', creator=entity, releases=releases)
-@app.route('/file/<uuid:ident>/history', methods=['GET'])
+@app.route('/file/<ident>/history', methods=['GET'])
def file_history(ident):
try:
- entity = api.get_file(str(ident))
- history = api.get_file_history(str(ident))
+ entity = api.get_file(ident)
+ history = api.get_file_history(ident)
except ApiException as ae:
abort(ae.status)
return render_template('entity_history.html',
@@ -138,10 +130,10 @@ def file_history(ident):
entity=entity,
history=history)
-@app.route('/file/<uuid:ident>/edit', methods=['GET'])
+@app.route('/file/<ident>/edit', methods=['GET'])
def file_edit_view(ident):
try:
- entity = api.get_file(str(ident))
+ entity = api.get_file(ident)
except ApiException as ae:
abort(ae.status)
return render_template('entity_edit.html')
@@ -157,20 +149,13 @@ def file_lookup():
abort(ae.status)
return redirect('/file/{}'.format(resp.ident))
-@app.route('/release/<uuid:ident>', methods=['GET'])
-def release_view(ident):
+@app.route('/file/<ident>', methods=['GET'])
+def file_view(ident):
try:
- entity = api.get_release(str(ident))
- files = api.get_release_files(str(ident))
- container = None
- if entity.container_id is not None:
- container = api.get_container(entity.container_id)
+ entity = api.get_file(ident)
except ApiException as ae:
abort(ae.status)
- authors = [c for c in entity.contribs if c.role in ('author', None)]
- authors = sorted(authors, key=lambda c: c.index)
- return render_template('release_view.html', release=entity,
- authors=authors, files=files, container=container)
+ return render_template('file_view.html', file=entity)
@app.route('/release/lookup', methods=['GET'])
def release_lookup():
@@ -196,11 +181,11 @@ def release_create():
edit = api.create_release(params=params)
return redirect("/release/{}".format(edit.ident))
-@app.route('/release/<uuid:ident>/history', methods=['GET'])
+@app.route('/release/<ident>/history', methods=['GET'])
def release_history(ident):
try:
- entity = api.get_release(str(ident))
- history = api.get_release_history(str(ident))
+ entity = api.get_release(ident)
+ history = api.get_release_history(ident)
except ApiException as ae:
abort(ae.status)
return render_template('entity_history.html',
@@ -209,28 +194,38 @@ def release_history(ident):
entity=entity,
history=history)
-@app.route('/release/<uuid:ident>/edit', methods=['GET'])
+@app.route('/release/<ident>/edit', methods=['GET'])
def release_edit_view(ident):
try:
- entity = api.get_release(str(ident))
+ entity = api.get_release(ident)
except ApiException as ae:
abort(ae.status)
return render_template('entity_edit.html')
-@app.route('/work/<uuid:ident>', methods=['GET'])
-def work_view(ident):
+@app.route('/release/<ident>', methods=['GET'])
+def release_view(ident):
try:
- entity = api.get_work(str(ident))
- releases = api.get_work_releases(str(ident))
+ entity = api.get_release(ident)
+ files = api.get_release_files(ident)
+ container = None
+ if entity.container_id is not None:
+ container = api.get_container(entity.container_id)
except ApiException as ae:
abort(ae.status)
- return render_template('work_view.html', work=entity, releases=releases)
+ authors = [c for c in entity.contribs if c.role in ('author', None)]
+ authors = sorted(authors, key=lambda c: c.index)
+ return render_template('release_view.html', release=entity,
+ authors=authors, files=files, container=container)
+
+@app.route('/work/create', methods=['GET'])
+def work_create_view():
+ return abort(404)
-@app.route('/work/<uuid:ident>/history', methods=['GET'])
+@app.route('/work/<ident>/history', methods=['GET'])
def work_history(ident):
try:
- entity = api.get_work(str(ident))
- history = api.get_work_history(str(ident))
+ entity = api.get_work(ident)
+ history = api.get_work_history(ident)
except ApiException as ae:
abort(ae.status)
return render_template('entity_history.html',
@@ -239,22 +234,22 @@ def work_history(ident):
entity=entity,
history=history)
-@app.route('/work/<uuid:ident>/edit', methods=['GET'])
+@app.route('/work/<ident>/edit', methods=['GET'])
def work_edit_view(ident):
try:
- entity = api.get_work(str(ident))
+ entity = api.get_work(ident)
except ApiException as ae:
abort(ae.status)
return render_template('entity_edit.html')
-@app.route('/editgroup/<int:ident>', methods=['GET'])
-def editgroup_view(ident):
+@app.route('/work/<ident>', methods=['GET'])
+def work_view(ident):
try:
- entity = api.get_editgroup(str(ident))
+ entity = api.get_work(ident)
+ releases = api.get_work_releases(ident)
except ApiException as ae:
- print(ae.body)
abort(ae.status)
- return render_template('editgroup_view.html', editgroup=entity)
+ return render_template('work_view.html', work=entity, releases=releases)
@app.route('/editgroup/current', methods=['GET'])
def editgroup_current():
@@ -262,6 +257,15 @@ def editgroup_current():
#eg = api.get_or_create_editgroup()
#return redirect('/editgroup/{}'.format(eg.id))
+@app.route('/editgroup/<int:ident>', methods=['GET'])
+def editgroup_view(ident):
+ try:
+ entity = api.get_editgroup(str(ident))
+ except ApiException as ae:
+ print(ae.body)
+ abort(ae.status)
+ return render_template('editgroup_view.html', editgroup=entity)
+
@app.route('/editor/<username>', methods=['GET'])
def editor_view(username):
entity = api.get_editor(username)
diff --git a/python/fatcat/templates/home.html b/python/fatcat/templates/home.html
index f1377954..e8a5da21 100644
--- a/python/fatcat/templates/home.html
+++ b/python/fatcat/templates/home.html
@@ -37,8 +37,8 @@ indexing (aka, linking together of pre-prints and final copies).
<br>journal article, pre-print, book
<br>published version of a Work
<td><a href="/release/create">Create</a>
- <td><a href="/release/00000000-0000-0000-4444-000000000002">Dummy</a>
- <br><a href="/release/00000000-0000-0000-4444-000000000003">Realistic</a>
+ <td><a href="/release/aaaaaaaaaaaaarceaaaaaaaaai">Dummy</a>
+ <br><a href="/release/aaaaaaaaaaaaarceaaaaaaaaam">Realistic</a>
<td><form class="" role="lookup" action="/release/lookup" method="get">
<div class="ui icon input">
<i class="search icon"></i>
@@ -48,8 +48,8 @@ indexing (aka, linking together of pre-prints and final copies).
<tr><td><b>Container</b>
<br>journal or serial
<td><a href="/container/create">Create</a>
- <td><a href="/container/00000000-0000-0000-1111-000000000002">Dummy</a>
- <br><a href="/container/00000000-0000-0000-1111-000000000003">Realistic</a>
+ <td><a href="/container/aaaaaaaaaaaaaeiraaaaaaaaai">Dummy</a>
+ <br><a href="/container/aaaaaaaaaaaaaeiraaaaaaaaam">Realistic</a>
<td><form class="" role="lookup" action="/container/lookup" method="get">
<div class="ui icon input">
<i class="search icon"></i>
@@ -60,8 +60,8 @@ indexing (aka, linking together of pre-prints and final copies).
<tr><td><b>Creator</b>
<br>authors, editors, translators
<td><!-- <a href="/creator/create">Create</a> -->
- <td><a href="/creator/00000000-0000-0000-2222-000000000002">Dummy</a>
- <br><a href="/creator/00000000-0000-0000-2222-000000000003">Realistic</a>
+ <td><a href="/creator/aaaaaaaaaaaaaircaaaaaaaaai">Dummy</a>
+ <br><a href="/creator/aaaaaaaaaaaaaircaaaaaaaaam">Realistic</a>
<td><form class="" role="lookup" action="/creator/lookup" method="get">
<div class="ui icon input">
<i class="search icon"></i>
@@ -71,8 +71,8 @@ indexing (aka, linking together of pre-prints and final copies).
<tr><td><b>File</b>
<br>specific digital blobs (immutable)
<td>
- <td><a href="/file/00000000-0000-0000-3333-000000000002">Dummy</a>
- <br><a href="/file/00000000-0000-0000-3333-000000000003">Realistic</a>
+ <td><a href="/file/aaaaaaaaaaaaamztaaaaaaaaai">Dummy</a>
+ <br><a href="/file/aaaaaaaaaaaaamztaaaaaaaaam">Realistic</a>
<td><form class="" role="lookup" action="/file/lookup" method="get">
<div class="ui icon input">
<i class="search icon"></i>
@@ -82,8 +82,8 @@ indexing (aka, linking together of pre-prints and final copies).
<tr><td><b>Work</b>
<br>for grouping Releases
<td>
- <td><a href="/work/00000000-0000-0000-5555-000000000002">Dummy</a>
- <br><a href="/work/00000000-0000-0000-5555-000000000003">Realistic</a>
+ <td><a href="/work/aaaaaaaaaaaaavkvaaaaaaaaai">Dummy</a>
+ <br><a href="/work/aaaaaaaaaaaaavkvaaaaaaaaam">Realistic</a>
<td>
</table>
diff --git a/python/tests/routes.py b/python/tests/routes.py
index 5a523efa..3391596e 100644
--- a/python/tests/routes.py
+++ b/python/tests/routes.py
@@ -19,18 +19,21 @@ def test_all_views(app):
for route in ('work', 'release', 'creator', 'container', 'file'):
print(route)
rv = app.get('/{}/9999999999'.format(route))
- assert rv.status_code == 404
+ assert rv.status_code == 400
rv = app.get('/{}/f1f046a3-45c9-ffff-ffff-ffffffffffff'.format(route))
+ assert rv.status_code == 400
+
+ rv = app.get('/{}/ccccccccccccccccccccccccca'.format(route))
assert rv.status_code == 404
- rv = app.get('/container/00000000-0000-0000-1111-000000000002')
+ rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai')
assert rv.status_code == 200
- rv = app.get('/container/00000000-0000-0000-1111-000000000002/history')
+ rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai/history')
assert rv.status_code == 200
- rv = app.get('/container/00000000-0000-0000-1111-000000000002/edit')
+ rv = app.get('/container/aaaaaaaaaaaaaeiraaaaaaaaai/edit')
assert rv.status_code == 200
rv = app.get('/container/create')
@@ -45,31 +48,31 @@ def test_all_views(app):
rv = app.get('/container/lookup?issnl=1234-5678')
assert rv.status_code == 302
- rv = app.get('/creator/00000000-0000-0000-2222-000000000002')
+ rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai')
assert rv.status_code == 200
- rv = app.get('/creator/00000000-0000-0000-2222-000000000002/history')
+ rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai/history')
assert rv.status_code == 200
- rv = app.get('/creator/00000000-0000-0000-2222-000000000002/edit')
+ rv = app.get('/creator/aaaaaaaaaaaaaircaaaaaaaaai/edit')
assert rv.status_code == 200
rv = app.get('/creator/lookup?orcid=0000-0003-2088-7465')
assert rv.status_code == 302
- rv = app.get('/file/00000000-0000-0000-3333-000000000002')
+ rv = app.get('/file/aaaaaaaaaaaaamztaaaaaaaaai')
assert rv.status_code == 200
rv = app.get('/file/lookup?sha1=7d97e98f8af710c7e7fe703abc8f639e0ee507c4')
assert rv.status_code == 302
- rv = app.get('/release/00000000-0000-0000-4444-000000000002')
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai')
assert rv.status_code == 200
- rv = app.get('/release/00000000-0000-0000-4444-000000000002/history')
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/history')
assert rv.status_code == 200
- rv = app.get('/release/00000000-0000-0000-4444-000000000002/edit')
+ rv = app.get('/release/aaaaaaaaaaaaarceaaaaaaaaai/edit')
assert rv.status_code == 200
rv = app.get('/release/create')
@@ -84,13 +87,13 @@ def test_all_views(app):
rv = app.get('/release/search')
assert rv.status_code == 200
- rv = app.get('/work/00000000-0000-0000-5555-000000000002')
+ rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai')
assert rv.status_code == 200
- rv = app.get('/work/00000000-0000-0000-5555-000000000002/history')
+ rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai/history')
assert rv.status_code == 200
- rv = app.get('/work/00000000-0000-0000-5555-000000000002/edit')
+ rv = app.get('/work/aaaaaaaaaaaaavkvaaaaaaaaai/edit')
assert rv.status_code == 200
rv = app.get('/work/create')