now have functional add/remove manual override to existing person

This commit is contained in:
2022-06-11 22:41:31 +10:00
parent 8c78d9e633
commit a53d4896b0
6 changed files with 175 additions and 84 deletions

View File

@@ -9,7 +9,7 @@ from status import st, Status
from flask_login import login_required, current_user
from werkzeug.utils import secure_filename
from shared import GenFace, GenThumb
from face import Face, FaceRefimgLink
from face import Face, FaceRefimgLink, FaceOverrideType, FaceNoMatchOverride, FaceManualOverride
import os
import json
import time
@@ -243,7 +243,6 @@ def find_persons(who):
resp[p.id]['firstname']=p.firstname
resp[p.id]['surname']=p.surname
print( resp )
return resp
################################################################################
@@ -253,15 +252,39 @@ def find_persons(who):
@login_required
def override_force_match():
person_id = request.form['person_id']
face_id = request.form['face_id']
p = Person.query.get(person_id);
if not p:
raise Exception("could not find person to add override too!")
face_id = request.form['face_id']
f = Face.query.get(face_id);
if not f:
raise Exception("could not find face to add override for!")
print( f"Being asked to force an override match for face_id {face_id}, for person: {p.tag} -- doing nothing for now" )
st.SetMessage( f"Being asked to force an override match for face_id {face_id}, for person: {p.tag} -- doing nothing for now" )
# might need to do something smarter here (reload to old view is good though & happens now, not sure why (last url)?)
return "ok"
mo = FaceManualOverride( face_id=f.id, face=f.face, person_id=p.id )
db.session.add( mo )
db.session.commit()
print( f"Placing an override match with face_id {face_id}, for person: {p.tag}" )
# this will reply to the Ajax / POST, and cause the page to re-draw with new face override to person_tag
resp={}
resp['person_tag']=p.tag
return resp
################################################################################
# /remove_override -> POST
################################################################################
@app.route("/remove_override", methods=["POST"])
@login_required
def remove_override():
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}" )
FaceManualOverride.query.filter( FaceManualOverride.face_id==face_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