From 81daf14fddf6c9671bbf065a07eb4e573749cbfe Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 17 Jun 2018 17:22:24 -0700 Subject: incorportate reverse lookups into web ui --- python/README_codegen.md | 3 +++ python/fatcat/routes.py | 9 ++++++--- python/fatcat/templates/creator_view.html | 12 ++++++++++++ python/fatcat/templates/release_view.html | 15 +++++++++++++-- python/fatcat/templates/work_view.html | 9 +++++---- 5 files changed, 39 insertions(+), 9 deletions(-) (limited to 'python') 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/', 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//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: +
    + {% for release in releases %} +
  • "{{ release.title }}", a {{ release.release_type }} published {{ release.release_date }} as {{ release.release_status }}. +
    {{ release.ident }} + {% endfor %} +
+{% 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 @@ -40,6 +40,19 @@ Raw JSON Object:
{{ release }}
--> +
+{% if files != [] %} +

Files believed to represent this release: +

+{% else %} +

There are no known files associated with this release (you could try other +releases for this work?). +{% endif %} +
{% if release.contribs.size != 0 %}

Full list of contributors (not just authors): @@ -76,6 +89,4 @@ Raw JSON Object:

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".
-{% if releases %} +{% if releases != [] %}

    -{% for r in releases %} -
      {{ r.title }} ({{ y.release_type }} - {{ y.date }}) -{% endfor %} + {% for release in releases %} +
    • "{{ release.title }}", a {{ release.release_type }} published {{ release.release_date }} as {{ release.release_status }}. +
      {{ release.ident }} + {% endfor %}
    {% else %}

    There are no known releases associated with this work. -- cgit v1.2.3