From 9dcae3138b6bfcf8d3eb09bc74c436418a892220 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Wed, 23 Oct 2019 08:43:25 +0100 Subject: [PATCH] Don't error on existing edit, ignore instead. --- app.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index 71aadaa..7c99f2c 100755 --- a/app.py +++ b/app.py @@ -93,9 +93,9 @@ def user_settings(): return 'flipped. find more is ' + display -def no_existing_edit(item_id, depicts_id): +def existing_edit(item_id, depicts_id): q = Edit.query.filter_by(painting_id=item_id, depicts_id=depicts_id) - return q.count() == 0 + return q.count() != 0 @app.route('/save/Q', methods=['POST']) def save(item_id): @@ -122,10 +122,11 @@ def save(item_id): database.session.add(depicts_item) database.session.commit() - assert no_existing_edit(item_id, depicts_id) - for depicts_qid in depicts: depicts_id = int(depicts_qid[1:]) + if existing_edit(item_id, depicts_id): + continue + r = create_claim(item_id, depicts_id, token) reply = r.json() if 'error' in reply: