More checks before save.
This commit is contained in:
parent
924b7a0818
commit
0a6f6308c1
8
app.py
8
app.py
|
@ -188,6 +188,10 @@ def user_settings():
|
|||
|
||||
return 'flipped. find more is ' + display
|
||||
|
||||
def no_existing_edit(item_id, depicts_id):
|
||||
q = Edit.query.filter(painting_id=item_id, depicts_id=depicts_id)
|
||||
return q.count() == 0
|
||||
|
||||
@app.route('/save/Q<int:item_id>', methods=['POST'])
|
||||
def save(item_id):
|
||||
depicts = request.form.getlist('depicts')
|
||||
|
@ -213,6 +217,10 @@ 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:])
|
||||
r = create_claim(item_id, depicts_id, token)
|
||||
reply = r.json()
|
||||
if 'error' in reply:
|
||||
|
|
Loading…
Reference in a new issue