From 07865fb5dd09a6658fd8ac7ed3579842fcb2a29f Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sun, 29 Sep 2019 13:15:34 +0100 Subject: [PATCH] Create painting item during save, if needed. --- app.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app.py b/app.py index 3639122..7f1e134 100755 --- a/app.py +++ b/app.py @@ -141,6 +141,15 @@ def save(item_id): token = get_token() + painting_item = PaintingItem.query.get(item_id) + if painting_item is None: + painting_entity = mediawiki.get_entity_with_cache(f'Q{item_id}') + label = get_entity_label(painting_entity) + painting_item = PaintingItem(item_id=item_id, label=label, entity=painting_entity) + database.session.add(painting_item) + + database.session.add(item) + for depicts_qid in depicts: depicts_id = int(depicts_qid[1:]) r = create_claim(item_id, depicts_id, token)