progress towards allowing overrides. dbox can now allow finding a person and clicking them to post to back-end.. More work to make this real, for now it goes through the routes but does not update the DB, see bottom of face.py for next steps

This commit is contained in:
2022-06-10 16:53:13 +10:00
parent b0779c2704
commit 8c78d9e633
3 changed files with 107 additions and 3 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 FaceRefimgLink
from face import Face, FaceRefimgLink
import os
import json
import time
@@ -225,3 +225,43 @@ def add_refimg():
except Exception as e:
st.SetMessage( f"<b>Failed to modify Refimg:</b>&nbsp;{e}", "danger" )
return redirect( url_for( 'person', id=person.id) )
################################################################################
# /find_persons/<who> -> POST (an arbitrary string to find a person (via
# name/tag match)
################################################################################
@app.route("/find_persons/<who>", methods=["POST"])
@login_required
def find_persons(who):
resp={}
people = Person.query.filter( Person.tag.ilike(f'%{who}%') | Person.firstname.ilike(f'%{who}%') | Person.surname.ilike(f'%{who}%') ).all();
for p in people:
resp[p.id]={}
resp[p.id]['id']=p.id
resp[p.id]['tag']=p.tag
resp[p.id]['firstname']=p.firstname
resp[p.id]['surname']=p.surname
print( resp )
return resp
################################################################################
# /override_force_match -> POST
################################################################################
@app.route("/override_force_match", methods=["POST"])
@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!")
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"