diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2018-06-17 17:22:24 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2018-06-17 17:22:24 -0700 |
commit | 81daf14fddf6c9671bbf065a07eb4e573749cbfe (patch) | |
tree | 73e0b6e7cb2fb8368d36908d27a690f7fefb93c8 /python | |
parent | 3eee396bde8c193029e72ab057471f13397fa05a (diff) | |
download | fatcat-81daf14fddf6c9671bbf065a07eb4e573749cbfe.tar.gz fatcat-81daf14fddf6c9671bbf065a07eb4e573749cbfe.zip |
incorportate reverse lookups into web ui
Diffstat (limited to 'python')
-rw-r--r-- | python/README_codegen.md | 3 | ||||
-rw-r--r-- | python/fatcat/routes.py | 9 | ||||
-rw-r--r-- | python/fatcat/templates/creator_view.html | 12 | ||||
-rw-r--r-- | python/fatcat/templates/release_view.html | 15 | ||||
-rw-r--r-- | python/fatcat/templates/work_view.html | 9 |
5 files changed, 39 insertions, 9 deletions
diff --git a/python/README_codegen.md b/python/README_codegen.md index cb2c230e..e259c16f 100644 --- a/python/README_codegen.md +++ b/python/README_codegen.md @@ -82,12 +82,15 @@ Class | Method | HTTP request | Description *DefaultApi* | [**create_work_batch**](docs/DefaultApi.md#create_work_batch) | **POST** /work/batch | *DefaultApi* | [**get_container**](docs/DefaultApi.md#get_container) | **GET** /container/{id} | *DefaultApi* | [**get_creator**](docs/DefaultApi.md#get_creator) | **GET** /creator/{id} | +*DefaultApi* | [**get_creator_releases**](docs/DefaultApi.md#get_creator_releases) | **GET** /creator/{id}/releases | *DefaultApi* | [**get_editgroup**](docs/DefaultApi.md#get_editgroup) | **GET** /editgroup/{id} | *DefaultApi* | [**get_editor**](docs/DefaultApi.md#get_editor) | **GET** /editor/{username} | *DefaultApi* | [**get_editor_changelog**](docs/DefaultApi.md#get_editor_changelog) | **GET** /editor/{username}/changelog | *DefaultApi* | [**get_file**](docs/DefaultApi.md#get_file) | **GET** /file/{id} | *DefaultApi* | [**get_release**](docs/DefaultApi.md#get_release) | **GET** /release/{id} | +*DefaultApi* | [**get_release_files**](docs/DefaultApi.md#get_release_files) | **GET** /release/{id}/files | *DefaultApi* | [**get_work**](docs/DefaultApi.md#get_work) | **GET** /work/{id} | +*DefaultApi* | [**get_work_releases**](docs/DefaultApi.md#get_work_releases) | **GET** /work/{id}/releases | *DefaultApi* | [**lookup_container**](docs/DefaultApi.md#lookup_container) | **GET** /container/lookup | *DefaultApi* | [**lookup_creator**](docs/DefaultApi.md#lookup_creator) | **GET** /creator/lookup | *DefaultApi* | [**lookup_file**](docs/DefaultApi.md#lookup_file) | **GET** /file/lookup | diff --git a/python/fatcat/routes.py b/python/fatcat/routes.py index ab7d2c92..47e5863e 100644 --- a/python/fatcat/routes.py +++ b/python/fatcat/routes.py @@ -35,9 +35,10 @@ def container_create(): def creator_view(ident): try: entity = api.get_creator(str(ident)) + releases = api.get_creator_releases(str(ident)) except ApiException as ae: abort(ae.status) - return render_template('creator_view.html', creator=entity) + return render_template('creator_view.html', creator=entity, releases=releases) @app.route('/file/<uuid:ident>', methods=['GET']) def file_view(ident): @@ -51,11 +52,12 @@ def file_view(ident): def release_view(ident): try: entity = api.get_release(str(ident)) + files = api.get_release_files(str(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) + return render_template('release_view.html', release=entity, authors=authors, files=files) #@app.route('/release/<uuid:ident>/changelog', methods=['GET']) #def release_changelog(ident): @@ -74,9 +76,10 @@ def release_view(ident): def work_view(ident): try: entity = api.get_work(str(ident)) + releases = api.get_work_releases(str(ident)) except ApiException as ae: abort(ae.status) - return render_template('work_view.html', work=entity) + return render_template('work_view.html', work=entity, releases=releases) @app.route('/work/create', methods=['GET']) def work_create(): diff --git a/python/fatcat/templates/creator_view.html b/python/fatcat/templates/creator_view.html index 210242aa..24dfdc56 100644 --- a/python/fatcat/templates/creator_view.html +++ b/python/fatcat/templates/creator_view.html @@ -22,4 +22,16 @@ Raw JSON Object: {{ creator }} --> +{% if releases != [] %} +Releases this creator has contributed to: +<ul> + {% for release in releases %} + <li>"{{ release.title }}", a {{ release.release_type }} published {{ release.release_date }} as <code>{{ release.release_status }}</code>. + <br><a href="/release/{{ release.ident }}"><code>{{ release.ident }}</code></a> + {% endfor %} +</ul> +{% else %} +This creator has not contributed to any releases. +{% endif %} + {% endblock %} diff --git a/python/fatcat/templates/release_view.html b/python/fatcat/templates/release_view.html index 6572919e..09a0b97b 100644 --- a/python/fatcat/templates/release_view.html +++ b/python/fatcat/templates/release_view.html @@ -41,6 +41,19 @@ Raw JSON Object: --> <br> +{% if files != [] %} +<p>Files believed to represent this release: +<ul> + {% for file in files %} + <li><a href="/file/{{ file.ident }}">{{ file.sha1}}</a> ({{ file.size }} bytes), at <a href="{{ file.url }}">{{ file.url }}</a> + {% endfor %} +</ul> +{% else %} +<p>There are no known files associated with this release (you could try other +releases for this work?). +{% endif %} + +<br> {% if release.contribs.size != 0 %} <p>Full list of contributors (not just authors): <table> @@ -76,6 +89,4 @@ Raw JSON Object: <p>No reference list available. {% endif %} - - {% endblock %} diff --git a/python/fatcat/templates/work_view.html b/python/fatcat/templates/work_view.html index 1a81d456..8fd384d6 100644 --- a/python/fatcat/templates/work_view.html +++ b/python/fatcat/templates/work_view.html @@ -20,11 +20,12 @@ still reference the same underlying "work". <br> -{% if releases %} +{% if releases != [] %} <ul> -{% for r in releases %} - <ul><a href="/release/{{ r.ident }}">{{ r.title }}</a> ({{ y.release_type }} - {{ y.date }}) -{% endfor %} + {% for release in releases %} + <li>"{{ release.title }}", a {{ release.release_type }} published {{ release.release_date }} as <code>{{ release.release_status }}</code>. + <br><a href="/release/{{ release.ident }}"><code>{{ release.ident }}</code></a> + {% endfor %} </ul> {% else %} <p>There are no known releases associated with this work. |