WIP: save depicts to paintings

This commit is contained in:
Edward Betts 2019-09-27 16:07:37 +01:00
parent b797af77dc
commit 46babe1a44
2 changed files with 16 additions and 0 deletions

6
app.py
View file

@ -119,6 +119,11 @@ def set_url_args(**new_args):
def init_profile(): def init_profile():
g.profiling = [] g.profiling = []
@app.route('/save/Q<int:item_id>', methods=['POST'])
def save(item_id):
depicts = request.form.getlist('depicts')
return repr(depicts)
@app.route("/property/P<int:property_id>") @app.route("/property/P<int:property_id>")
def property_query_page(property_id): def property_query_page(property_id):
pid = f'P{property_id}' pid = f'P{property_id}'
@ -343,6 +348,7 @@ def item_page(item_id):
return render_template('item.html', return render_template('item.html',
qid=qid, qid=qid,
item_id=item_id,
item=item, item=item,
catalog=catalog, catalog=catalog,
catalog_url=catalog_url, catalog_url=catalog_url,

View file

@ -84,11 +84,17 @@
</div> </div>
</div> </div>
<form method="POST" action="{{ url_for('save', item_id=item_id) }}">
{% raw %} {% raw %}
<div id="app" class="mt-2"> <div id="app" class="mt-2">
<h3>what can you see in this painting?</h3> <h3>what can you see in this painting?</h3>
<div v-if="new_depicts.length">
<div>{{ new_depicts.length }} new items to add to painting depicts statement</div>
</div>
<div v-for="(hit, index) in new_depicts"> <div v-for="(hit, index) in new_depicts">
<input type="hidden" name="depicts" :value="hit.qid">
<div> <div>
{{ hit.label }} {{ hit.label }}
<span v-if="hit.alt_label">({{ hit.alt_label }})</span> <span v-if="hit.alt_label">({{ hit.alt_label }})</span>
@ -102,7 +108,10 @@
</div> </div>
</div> </div>
<button type="submit" v-if="new_depicts.length" class="btn btn-primary">add these to painting on Wikidata</button>
<input class="form-control-lg mt-2 w-100" autofocus autocomplete="off" v-model.trim="searchTerms" @input="search" /> <input class="form-control-lg mt-2 w-100" autofocus autocomplete="off" v-model.trim="searchTerms" @input="search" />
<div id="item-list"> <div id="item-list">
<div v-for="hit in hits"> <div v-for="hit in hits">
<div> <div>
@ -119,6 +128,7 @@
</div> </div>
</div> </div>
{% endraw %} {% endraw %}
</form>
</div> </div>
<div class="flex-shrink-1 vh-100"> <div class="flex-shrink-1 vh-100">
<img src="{{ image.thumburl }}" /> <img src="{{ image.thumburl }}" />