can now add/remove overrides (manual or no matchx3) in any sequence of load/reload, or back-to-back and it all works

This commit is contained in:
2022-06-13 18:30:13 +10:00
parent 83819a0cb3
commit b935aa8ab8
5 changed files with 179 additions and 74 deletions

View File

@@ -270,17 +270,17 @@ def override_force_match():
resp={}
resp['person_tag']=p.tag
return resp
################################################################################
# /remove_override -> POST
# /remove_override_force_match -> POST
################################################################################
@app.route("/remove_override", methods=["POST"])
@app.route("/remove_override_force_match", methods=["POST"])
@login_required
def remove_override():
def remove_override_force_match():
face_id = request.form['face_id']
person_tag = request.form['person_tag']
file_eid = request.form['file_eid']
print( f"Remove override with face_id={face_id} to person_tag={person_tag}" )
print( f"Remove override force match of face_id={face_id} to person_tag={person_tag}" )
FaceManualOverride.query.filter( FaceManualOverride.face_id==face_id ).delete()
db.session.commit()
@@ -288,3 +288,47 @@ def remove_override():
# this will reply to the Ajax / POST, and cause the page to re-draw with new face override
resp={}
return resp
################################################################################
# /remove_override_no_match -> POST
################################################################################
@app.route("/remove_override_no_match", methods=["POST"])
@login_required
def remove_override_no_match():
face_id = request.form['face_id']
type_id = request.form['type_id']
print( f"Remove override of no match (type_id={type_id}) for face_id={face_id}" )
FaceNoMatchOverride.query.filter( FaceNoMatchOverride.face_id==face_id, FaceNoMatchOverride.type_id==type_id ).delete()
db.session.commit()
# this will reply to the Ajax / POST, and cause the page to re-draw with new face override
resp={}
return resp
################################################################################
# /add_no_match_override -> POST
################################################################################
@app.route("/add_no_match_override", methods=["POST"])
@login_required
def add_no_match_override():
face_id = request.form['face_id']
f = Face.query.get(face_id);
if not f:
raise Exception("could not find face to add override too!")
type_id = request.form['type_id']
t = FaceOverrideType.query.get(type_id);
if not t:
raise Exception("could not find override_type to add override for!")
nmo = FaceNoMatchOverride( face_id=f.id, face=f.face, type_id=t.id )
db.session.add( nmo )
db.session.commit()
print( f"Placing an override of NO Match for face_id {face_id}" )
# this will reply to the Ajax / POST, and cause the page to re-draw with new face override to person_tag
resp={}
resp['type']=t.name
return resp