diff --git a/app.py b/app.py index 9c0c1e4..9888a49 100755 --- a/app.py +++ b/app.py @@ -377,17 +377,39 @@ def item_page(item_id): people = human.from_name(label) if label else None + label_languages = label_and_language['languages'] if label_and_language else [] + show_translation_links = all(lang.code != 'en' for lang in label_languages) + artwork_item = Item.query.get(item_id) if artwork_item is None: - artwork_item = Item(item_id=item_id, label=label, entity=entity) + + if not wdqs.is_artificial_physical_object(qid): + return render_template('not_artwork.html', + qid=qid, + item_id=item_id, + item=item, + labels=find_more_props, + entity=item.entity, + username=g.user, + label=label, + label_languages=label_languages, + show_translation_links=show_translation_links, + image=image, + other=other, + title=item.display_title) + + modified = datetime.strptime(entity['modified'], "%Y-%m-%dT%H:%M:%SZ") + + artwork_item = Item(item_id=item_id, + entity=entity, + lastrevid=entity['lastrevid'], + modified=modified) database.session.add(artwork_item) catalog = wd_catalog.get_catalog_from_artwork(entity) if not catalog.get('institution'): catalog['institution'] = get_institution(entity, other) - label_languages = label_and_language['languages'] if label_and_language else [] - show_translation_links = all(lang.code != 'en' for lang in label_languages) return render_template('item.html', qid=qid, item_id=item_id, diff --git a/templates/not_artwork.html b/templates/not_artwork.html new file mode 100644 index 0000000..ab8da68 --- /dev/null +++ b/templates/not_artwork.html @@ -0,0 +1,76 @@ +{% extends "base.html" %} + +{% block title %}{{ label or 'no label' }} ({{qid }}){% endblock %} + +{% block style %} + +{% endblock %} + +{% block content %} +
+
+
+ +
+
+

{{ self.title() }}

+ {% if label_languages %} +

Label from: + {% for lang in label_languages %} + {{ lang.label }} ({{ lang.code }}) + {% if show_translation_links %} + [translate] + {% endif %} + {% endfor %} +

+ {% endif %} + + + + +
+ {% for hit in hits %} +

+ url: {{ hit.url }}
+ label: {{ hit.label }}
+ qid: {{ hit.qid }}
+ sources: {{ hit.sources() }}
+

+ {% endfor %} + +
+ {% for key, prop_label in labels.items() %} + {% set claims = entity['claims'][key] %} + {% if claims %} +
+ {{ prop_label }}: + {% for claim in claims %} + {% if 'datavalue' in claim.mainsnak %} + {% set claim_qid = claim.mainsnak.datavalue.value.id %} + {{ other[claim_qid] or '[ label missing ]' }} ({{ claim_qid }}) + {% else %} + no value + {% endif %} + {% endfor %} +
+ {% endif %} + {% endfor %} + +
+
+ + + +
+
+
+{% endblock %}