big change to get metadata working fully in DB and on Filesystem, and recover from most common scenarios, improved GUI as well for allowing an immediate search after adding refimg as well
This commit is contained in:
60
person.py
60
person.py
@@ -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, FaceOverrideType, FaceNoMatchOverride, FaceManualOverride
|
||||
from face import Face, FaceRefimgLink, FaceOverrideType, FaceNoMatchOverride, FaceForceMatchOverride
|
||||
from path import Path, PathType
|
||||
from job import JobExtra, NewJob
|
||||
|
||||
@@ -250,6 +250,10 @@ def person(id):
|
||||
return render_template("base.html" )
|
||||
|
||||
for r in person.refimg:
|
||||
# in case DB data gets broken, just fix it - still keeps happening
|
||||
if r.face_locn[0]=='{':
|
||||
r.face_locn[0]='['
|
||||
r.face_locn[-1]=']'
|
||||
r.tmp_locn=json.loads(r.face_locn)
|
||||
form = PersonForm(request.values, obj=person)
|
||||
return render_template("person.html", person=person, form=form, page_title = page_title)
|
||||
@@ -333,11 +337,11 @@ def add_refimg_to_person():
|
||||
return resp
|
||||
|
||||
################################################################################
|
||||
# /override_force_match -> POST
|
||||
# /add_force_match_override -> POST
|
||||
################################################################################
|
||||
@app.route("/override_force_match", methods=["POST"])
|
||||
@app.route("/add_force_match_override", methods=["POST"])
|
||||
@login_required
|
||||
def override_force_match():
|
||||
def add_force_match_override():
|
||||
person_id = request.form['person_id']
|
||||
p = Person.query.get(person_id);
|
||||
if not p:
|
||||
@@ -348,10 +352,17 @@ def override_force_match():
|
||||
if not f:
|
||||
raise Exception("could not find face to add override for!")
|
||||
|
||||
mo = FaceManualOverride( face_id=f.id, person_id=p.id )
|
||||
mo = FaceForceMatchOverride( face_id=f.id, person_id=p.id )
|
||||
db.session.add( mo )
|
||||
db.session.commit()
|
||||
|
||||
jex=[]
|
||||
jex.append( JobExtra( name="which", value="add_force_match_override" ) )
|
||||
jex.append( JobExtra( name="face_id", value=f.id ) )
|
||||
jex.append( JobExtra( name="person_id", value=p.id ) )
|
||||
# dont do status update here, the F/E is in the middle of a dbox, just send metadata through to the B/E
|
||||
NewJob( "metadata", 0, None, jex )
|
||||
|
||||
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={}
|
||||
@@ -359,29 +370,40 @@ def override_force_match():
|
||||
return resp
|
||||
|
||||
################################################################################
|
||||
# /remove_override_force_match -> POST
|
||||
# /remove_force_match_override -> POST
|
||||
################################################################################
|
||||
@app.route("/remove_override_force_match", methods=["POST"])
|
||||
@app.route("/remove_force_match_override", methods=["POST"])
|
||||
@login_required
|
||||
def remove_override_force_match():
|
||||
def remove_force_match_override():
|
||||
face_id = request.form['face_id']
|
||||
person_tag = request.form['person_tag']
|
||||
file_eid = request.form['file_eid']
|
||||
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()
|
||||
FaceForceMatchOverride.query.filter( FaceForceMatchOverride.face_id==face_id ).delete()
|
||||
db.session.commit()
|
||||
|
||||
print( f"person_tag={person_tag}" )
|
||||
# needed to use person_id in job below (allows consistent processing in job_mgr)
|
||||
p=Person.query.filter(Person.tag==person_tag).one()
|
||||
|
||||
jex=[]
|
||||
jex.append( JobExtra( name="which", value="remove_force_match_override" ) )
|
||||
jex.append( JobExtra( name="face_id", value=face_id ) )
|
||||
jex.append( JobExtra( name="person_id", value=p.id ) )
|
||||
# dont do status update here, the F/E is in the middle of a dbox, just send metadata through to the B/E
|
||||
NewJob( "metadata", 0, None, jex )
|
||||
|
||||
# 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
|
||||
# /remove_no_match_override -> POST
|
||||
################################################################################
|
||||
@app.route("/remove_override_no_match", methods=["POST"])
|
||||
@app.route("/remove_no_match_override", methods=["POST"])
|
||||
@login_required
|
||||
def remove_override_no_match():
|
||||
def remove_no_match_override():
|
||||
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}" )
|
||||
@@ -389,6 +411,13 @@ def remove_override_no_match():
|
||||
FaceNoMatchOverride.query.filter( FaceNoMatchOverride.face_id==face_id, FaceNoMatchOverride.type_id==type_id ).delete()
|
||||
db.session.commit()
|
||||
|
||||
jex=[]
|
||||
jex.append( JobExtra( name="which", value="remove_no_match_override" ) )
|
||||
jex.append( JobExtra( name="face_id", value=face_id ) )
|
||||
jex.append( JobExtra( name="type_id", value=type_id ) )
|
||||
# dont do status update here, the F/E is in the middle of a dbox, just send metadata through to the B/E
|
||||
NewJob( "metadata", 0, None, jex )
|
||||
|
||||
# this will reply to the Ajax / POST, and cause the page to re-draw with new face override
|
||||
resp={}
|
||||
return resp
|
||||
@@ -414,6 +443,13 @@ def add_no_match_override():
|
||||
db.session.add( nmo )
|
||||
db.session.commit()
|
||||
|
||||
jex=[]
|
||||
jex.append( JobExtra( name="which", value="add_no_match_override" ) )
|
||||
jex.append( JobExtra( name="face_id", value=f.id ) )
|
||||
jex.append( JobExtra( name="type_id", value=t.id ) )
|
||||
# dont do status update here, the F/E is in the middle of a dbox, just send metadata through to the B/E
|
||||
NewJob( "metadata", 0, None, jex )
|
||||
|
||||
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={}
|
||||
|
||||
Reference in New Issue
Block a user