pass amendmentTypes to client in query_data, make query_data single func to remove duplicate code, reference new amend.py for class defintions
This commit is contained in:
43
files.py
43
files.py
@@ -22,6 +22,7 @@ import pytz
|
||||
import html
|
||||
from flask_login import login_required, current_user
|
||||
from types import SimpleNamespace
|
||||
from amend import EntryAmendment, AmendmentType
|
||||
|
||||
# Local Class imports
|
||||
################################################################################
|
||||
@@ -33,6 +34,7 @@ from person import Refimg, Person, PersonRefimgLink
|
||||
from settings import Settings, SettingsIPath, SettingsSPath, SettingsRBPath
|
||||
from shared import SymlinkName, ICON, PA
|
||||
from dups import Duplicates
|
||||
from amend import getAmendments
|
||||
from face import Face, FaceFileLink, FaceRefimgLink, FaceOverrideType, FaceNoMatchOverride, FaceForceMatchOverride
|
||||
|
||||
# pylint: disable=no-member
|
||||
@@ -126,20 +128,6 @@ class FileType(PA,db.Model):
|
||||
id = db.Column(db.Integer, db.Sequence('file_type_id_seq'), primary_key=True )
|
||||
name = db.Column(db.String, unique=True, nullable=False )
|
||||
|
||||
class AmendmentType(PA,db.Model):
|
||||
__tablename__ = "amendment_type"
|
||||
id = db.Column(db.Integer, db.Sequence('file_type_id_seq'), primary_key=True )
|
||||
which = db.Column(db.String, nullable=False )
|
||||
what = db.Column(db.String, nullable=False )
|
||||
colour = db.Column(db.String, nullable=False )
|
||||
|
||||
class EntryAmendment(PA,db.Model):
|
||||
__tablename__ = "entry_amendment"
|
||||
eid = db.Column(db.Integer, db.ForeignKey("entry.id"), primary_key=True )
|
||||
amend_type = db.Column(db.Integer, db.ForeignKey("amendment_type.id"))
|
||||
type = db.relationship("AmendmentType", backref="entry_amendment")
|
||||
|
||||
|
||||
################################################################################
|
||||
# this is how we order all queries based on value of 'noo' - used with
|
||||
# access *order_map.get(OPT.noo)
|
||||
@@ -282,6 +270,8 @@ entries_schema = EntrySchema(many=True)
|
||||
FOT_Schema = FaceOverrideTypeSchema(many=True)
|
||||
path_Schema = PathSchema(many=True)
|
||||
person_Schema = PersonSchema(many=True)
|
||||
et_schema = AmendmentTypeSchema(many=True)
|
||||
ea_schema = EntryAmendmentSchema(many=True)
|
||||
|
||||
################################################################################
|
||||
# /get_entries_by_ids -> route where we supply list of entry ids (for next/prev
|
||||
@@ -319,9 +309,7 @@ def process_ids():
|
||||
# get any pending entry amendments
|
||||
stmt = select(EntryAmendment).join(AmendmentType)
|
||||
ea = db.session.execute(stmt).unique().scalars().all()
|
||||
ea_schema = EntryAmendmentSchema(many=True)
|
||||
ea_data=ea_schema.dump(ea)
|
||||
print( ea_data )
|
||||
|
||||
return jsonify(entries=entries_schema.dump(sorted_data), amend=ea_data)
|
||||
|
||||
@@ -379,17 +367,21 @@ def getPeople():
|
||||
people=db.session.execute(stmt).scalars().all()
|
||||
return person_Schema.dump(people)
|
||||
|
||||
|
||||
################################################################################
|
||||
# Get all relevant Entry.ids based on search_term passed in and OPT visuals
|
||||
################################################################################
|
||||
def GetSearchQueryData(OPT):
|
||||
def initQueryData():
|
||||
query_data={}
|
||||
query_data['entry_list']=None
|
||||
query_data['root_eid']=0
|
||||
query_data['NMO'] = getFOT()
|
||||
query_data['move_paths'] = getMoveDetails()
|
||||
query_data['people'] = getPeople()
|
||||
query_data['amendTypes'] = et_schema.dump( getAmendments() )
|
||||
return query_data
|
||||
|
||||
################################################################################
|
||||
# Get all relevant Entry.ids based on search_term passed in and OPT visuals
|
||||
################################################################################
|
||||
def GetSearchQueryData(OPT):
|
||||
query_data=initQueryData()
|
||||
|
||||
search_term = OPT.search_term
|
||||
# turn * wildcard into sql wildcard of %
|
||||
@@ -426,11 +418,7 @@ def GetSearchQueryData(OPT):
|
||||
# Get all relevant Entry.ids based on files_ip/files_sp/files_rbp and OPT visuals
|
||||
#################################################################################
|
||||
def GetQueryData( OPT ):
|
||||
query_data={}
|
||||
query_data['entry_list']=None
|
||||
query_data['NMO'] = getFOT()
|
||||
query_data['move_paths'] = getMoveDetails()
|
||||
query_data['people'] = getPeople()
|
||||
query_data=initQueryData()
|
||||
|
||||
# always get the top of the (OPT.prefix) Path's eid and keep it for OPT.folders toggling/use
|
||||
dir_stmt=(
|
||||
@@ -721,7 +709,8 @@ def transform():
|
||||
@login_required
|
||||
def check_transform_job():
|
||||
job_id = request.form['job_id']
|
||||
job = Job.query.get(job_id)
|
||||
stmt=select(Job).where(Job.id==job_id)
|
||||
job=db.session.execute(stmt).scalars().one_or_none()
|
||||
j=jsonify( finished=False )
|
||||
if job.pa_job_state == 'Completed':
|
||||
id=[jex.value for jex in job.extra if jex.name == "id"][0]
|
||||
|
||||
Reference in New Issue
Block a user