Warn for non-artwork items.
This commit is contained in:
parent
54b94923e6
commit
63392b63bf
28
app.py
28
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,
|
||||
|
|
76
templates/not_artwork.html
Normal file
76
templates/not_artwork.html
Normal file
|
@ -0,0 +1,76 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ label or 'no label' }} ({{qid }}){% endblock %}
|
||||
|
||||
{% block style %}
|
||||
<style>
|
||||
div.description { margin-left: 2em; color: rgb(96, 96, 96); }
|
||||
span.description { color: rgb(96, 96, 96); }
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid mt-2">
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<img src="{{ image.thumburl }}" class="w-100" />
|
||||
</div>
|
||||
<div class="col-md">
|
||||
<h1>{{ self.title() }}</h1>
|
||||
{% if label_languages %}
|
||||
<p>Label from:
|
||||
{% for lang in label_languages %}
|
||||
{{ lang.label }} ({{ lang.code }})
|
||||
{% if show_translation_links %}
|
||||
<a href="https://translate.google.com/#view=home&op=translate&sl={{lang.code}}&tl=en&text={{label}}" target="translation">[translate]</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<div class="m-2">
|
||||
<a href="https://www.wikidata.org/wiki/{{ qid }}" class="btn btn-primary">view on Wikidata</a>
|
||||
<a href="{{ url_for('random_artwork') }}" class="btn btn-primary">skip this artwork</a>
|
||||
<a href="{{ url_for('browse_page') }}" class="btn btn-primary">browse artworks</a>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
{% for hit in hits %}
|
||||
<p>
|
||||
url: {{ hit.url }}<br>
|
||||
label: {{ hit.label }}<br>
|
||||
qid: {{ hit.qid }}<br>
|
||||
sources: {{ hit.sources() }}<br>
|
||||
</p>
|
||||
{% endfor %}
|
||||
|
||||
<div>
|
||||
{% for key, prop_label in labels.items() %}
|
||||
{% set claims = entity['claims'][key] %}
|
||||
{% if claims %}
|
||||
<div>
|
||||
<strong>{{ prop_label }}</strong>:
|
||||
{% for claim in claims %}
|
||||
{% if 'datavalue' in claim.mainsnak %}
|
||||
{% set claim_qid = claim.mainsnak.datavalue.value.id %}
|
||||
<a href="https://www.wikidata.org/wiki/{{ claim_qid }}">{{ other[claim_qid] or '[ label missing ]' }}</a> ({{ claim_qid }})
|
||||
{% else %}
|
||||
<i>no value</i>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info mt-4" role="alert">
|
||||
This item is not a work of art.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
Loading…
Reference in a new issue