Create PaintingItem objects and save lastrevid
This commit is contained in:
parent
ab51e83e9c
commit
2df8958a1f
13
app.py
13
app.py
|
@ -4,7 +4,7 @@ from flask import Flask, render_template, url_for, redirect, request, g, jsonify
|
||||||
from depicts import (utils, wdqs, commons, mediawiki, painting, saam, database,
|
from depicts import (utils, wdqs, commons, mediawiki, painting, saam, database,
|
||||||
dia, rijksmuseum, npg, museodelprado, barnesfoundation,
|
dia, rijksmuseum, npg, museodelprado, barnesfoundation,
|
||||||
wd_catalog)
|
wd_catalog)
|
||||||
from depicts.model import DepictsItem, DepictsItemAltLabel, Edit
|
from depicts.model import DepictsItem, DepictsItemAltLabel, Edit, PaintingItem
|
||||||
from requests_oauthlib import OAuth1Session
|
from requests_oauthlib import OAuth1Session
|
||||||
from urllib.parse import urlencode
|
from urllib.parse import urlencode
|
||||||
from werkzeug.exceptions import InternalServerError
|
from werkzeug.exceptions import InternalServerError
|
||||||
|
@ -147,9 +147,13 @@ def save(item_id):
|
||||||
if 'error' in reply:
|
if 'error' in reply:
|
||||||
return 'error:' + r.text
|
return 'error:' + r.text
|
||||||
print(r.text)
|
print(r.text)
|
||||||
|
saved = r.json()
|
||||||
|
lastrevid = saved['pageinfo']['lastrevid']
|
||||||
|
assert saved['success'] == 1
|
||||||
edit = Edit(username=username,
|
edit = Edit(username=username,
|
||||||
painting_id=item_id,
|
painting_id=item_id,
|
||||||
depicts_id=depicts_id)
|
depicts_id=depicts_id,
|
||||||
|
lastrevid=lastrevid)
|
||||||
database.session.add(edit)
|
database.session.add(edit)
|
||||||
database.session.commit()
|
database.session.commit()
|
||||||
|
|
||||||
|
@ -387,6 +391,11 @@ def item_page(item_id):
|
||||||
label = get_entity_label(entity)
|
label = get_entity_label(entity)
|
||||||
other = get_other(item.entity)
|
other = get_other(item.entity)
|
||||||
|
|
||||||
|
painting_item = PaintingItem.get(item_id)
|
||||||
|
if painting_item is None:
|
||||||
|
painting_item = PaintingItem(item_id=item_id, label=label, entity=entity)
|
||||||
|
database.session.add(painting_item)
|
||||||
|
|
||||||
catalog_ids = wd_catalog.find_catalog_id(entity)
|
catalog_ids = wd_catalog.find_catalog_id(entity)
|
||||||
catalog_detail = []
|
catalog_detail = []
|
||||||
for property_id in sorted(catalog_ids):
|
for property_id in sorted(catalog_ids):
|
||||||
|
|
Loading…
Reference in a new issue