From a24e3a67987e7a070eca562ce1cf30a59c206e06 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Thu, 31 Jan 2019 17:10:33 -0800 Subject: tweaks and fixes for new container extra schema --- python/fatcat_web/routes.py | 13 +++++--- python/fatcat_web/templates/container_view.html | 44 +++++++++++++++---------- python/fatcat_web/templates/release_view.html | 42 +++++++++++------------ 3 files changed, 56 insertions(+), 43 deletions(-) diff --git a/python/fatcat_web/routes.py b/python/fatcat_web/routes.py index 926d5340..21f81eae 100644 --- a/python/fatcat_web/routes.py +++ b/python/fatcat_web/routes.py @@ -8,6 +8,7 @@ from fatcat_web import app, api, auth_api, priv_api from fatcat_web.auth import handle_token_login, handle_logout, load_user, handle_ia_xauth from fatcat_client.rest import ApiException from fatcat_web.search import do_search +from fatcat_tools.transforms import * ### Views ################################################################### @@ -86,6 +87,7 @@ def container_view(ident): return redirect('/container/{}'.format(entity.redirect)) if entity.state == "deleted": return render_template('deleted_entity.html', entity=entity) + entity.es = container_to_elasticsearch(entity, force_bool=False) return render_template('container_view.html', container=entity) @app.route('/creator//history', methods=['GET']) @@ -236,17 +238,18 @@ def release_edit_view(ident): @app.route('/release/', methods=['GET']) def release_view(ident): try: - 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) + entity = api.get_release(ident, expand="container,files,filesets,webcaptures") + files = entity.files + container = entity.container except ApiException as ae: abort(ae.status) if entity.state == "redirect": return redirect('/release/{}'.format(entity.redirect)) if entity.state == "deleted": return render_template('deleted_entity.html', entity=entity) + if entity.container: + entity.container.es = container_to_elasticsearch(entity.container, force_bool=False) + entity.es = release_to_elasticsearch(entity, force_bool=False) authors = [c for c in entity.contribs if c.role in ('author', None)] authors = sorted(authors, key=lambda c: c.index) for fe in files: diff --git a/python/fatcat_web/templates/container_view.html b/python/fatcat_web/templates/container_view.html index 4a175a5d..ffe01185 100644 --- a/python/fatcat_web/templates/container_view.html +++ b/python/fatcat_web/templates/container_view.html @@ -15,14 +15,11 @@

Publisher: {% if container.publisher != None %}{{ container.publisher }}{% else %}Unknown{% endif %} -{% if (container.extra != None) and (container.extra['url'] != None) and (container.extra['url']|length > 0) %} -
Homepage:  {{ container.extra['url'] }} -{% endif %} -{% if container.wikidata_qid != None %} -
Wikidata Entity:  {{ container.wikidata_qid }} +{% if (container.extra != None) and (container.extra['urls'] != None) and (container.extra['urls']|length > 0) %} +
Homepage:  {{ container.extra['urls'][0] }} {% endif %} -{% if container.extra != None %} +{% if container.extra %}

Extra Metadata (raw JSON)

{% for (key, value) in container.extra.items() %} {{ key }}: {{ value }}
@@ -38,15 +35,16 @@ Raw Object:
-{% if container.extra.is_oa == True %} +{% if container.es and container.es.is_oa == True %} Open Access Publisher -{% elif container.extra.is_oa == False %} +{% elif container.es and container.es.is_oa == False %} Not Open Access {% else %} Unknown OA Status {% endif %}
+{% if container.issnl != None or container.wikidata_qid != None %} {% if container.issnl != None %} ISSN-L?  {{ container.issnl }} @@ -56,33 +54,45 @@ Raw Object: {% if container.extra != None and container.extra.ISSNe != None and (container.extra.ISSNe|length > 0) %}
Electronic:  {{ container.extra.ISSNe }} {% endif %} +{% endif %} +{% if container.wikidata_qid != None %} +
Wikidata:  {{ container.wikidata_qid }} +{% endif %}
{% endif %} +{% if (container.es and container.es != None) %} Directory Listings
-{% if (container.extra != None) %} - {% if container.extra.in_doaj == True %} + {% if container.es.in_doaj == True %} In DOAJ
- {% elif container.extra.in_doaj == False %} + {% elif container.es.in_doaj == False %} Not in DOAJ
{% endif %} - {% if container.extra.in_road == True %} + + {% if container.es.in_road == True %} In ISSN ROAD
- {% elif container.extra.in_road == False %} + {% elif container.es.in_road == False %} Not in ISSN ROAD
{% endif %} - {% if container.extra.is_kept == True %} + + {% if container.es.in_kbart == True %} In Keepers Registery
- {% elif container.extra.is_kept == False %} + {% elif container.es.in_kbart == False %} Not in Keepers Registry
{% endif %} -{% endif %} + + {% if container.extra and container.extra.sherpa_romeo and container.extra.sherpa_romeo.color %} + SHERPA/RoMEO color: {{ container.extra.sherpa_romeo.color }} + {% endif %}
+{% endif %} Lookup Links
SHERPA/RoMEO (access policies) -
wikidata.org +{% if not container.wikidata_qid %} +
wikidata.org +{% endif %}
Fatcat Bits diff --git a/python/fatcat_web/templates/release_view.html b/python/fatcat_web/templates/release_view.html index c81bf478..3716f0cb 100644 --- a/python/fatcat_web/templates/release_view.html +++ b/python/fatcat_web/templates/release_view.html @@ -154,20 +154,20 @@ This release citing other releases. {% if ref.container_name %}{{ ref.container_name }}.{% endif %} {% if ref.year %}{{ ref.year }}{% endif %} {% if ref.locator %}{{ ref.locator }}{% endif %} - {% elif ref.extra %} + {% elif ref.extra != None %} {% if ref.extra.get('author') %}{{ ref.extra['author'] }}.{% endif %} {% if ref.extra.get('article-title') %}{{ ref.extra['article-title'] }}.{% endif %} {% if ref.container_name %}{{ ref.container_name }}.{% endif %} {% if ref.year %}{{ ref.year }}.{% endif %} - {% elif ref.extra and ref.extra.unstructured %} - {{ ref.extra.unstructured }} + {% if ref.extra.unstructured %}{{ ref.extra.unstructured }}{% endif %} {% else %} unknown {% endif %} {% if ref.target_release_id != None %} - (fatcat release) -{# {% elif ref.extra != None and ref.extra.doi != None %} - (DOI: {{ ref.extra.get('doi') }}) #} + (fatcat entry) + {% endif %} + {% if ref.extra != None and ref.extra.doi %} + (DOI: {{ ref.extra.doi }}) {% endif %} {% endfor %} @@ -186,13 +186,13 @@ This release citing other releases. {% if release.release_type != None %}
-Release Type {{ release.release_type }} +Release Type  {{ release.release_type }}
{% endif %} {% if release.doi %} {% endif %} {% if release.isbn13 != None %} @@ -210,37 +210,37 @@ This release citing other releases.
{% endif %} -{% if container != None %} +{% if container != None and container.es != None %}
Container Metadata
-{% if container.extra.is_oa == True %} +{% if container.es.is_oa == True %} Open Access Publication
-{% elif container.extra.is_oa == False %} +{% elif container.es.is_oa == False %} Not Open Access
{% else %} Unknown OA Status
{% endif %} -{% if (container.extra != None) %} - {% if container.extra.in_doaj == True %} +{% if (container.es != None) %} + {% if container.es.in_doaj == True %} In DOAJ
- {% elif container.extra.in_doaj == False %} + {% elif container.es.in_doaj == False %} Not in DOAJ
{% endif %} - {% if container.extra.in_road == True %} + {% if container.es.in_road == True %} In ISSN ROAD
- {% elif container.extra.in_road == False %} + {% elif container.es.in_road == False %} Not in ISSN ROAD
{% endif %} - {% if container.extra.is_kept == True %} + {% if container.es.in_kbart == True %} In Keepers Registery
- {% elif container.extra.is_kept == False %} + {% elif container.es.in_kbart == False %} Not in Keepers Registry
{% endif %} {% endif %} {% if container.issnl != None %} - ISSN-L:  {{ container.issnl }}
+ ISSN-L:  {{ container.issnl }}
{% endif %} - Fatcat:  {{ container.ident }}
+ Fatcat Entry
{% endif %} @@ -273,7 +273,7 @@ This release citing other releases. Fatcat Bits

State is "{{ release.state }}". Revision:
{{ release.revision }} -
As JSON object via API +
As JSON object via API

-- cgit v1.2.3