diff --git a/files.py b/files.py index 515d087..4c41e57 100644 --- a/files.py +++ b/files.py @@ -1,5 +1,5 @@ from flask_wtf import FlaskForm -from flask import request, render_template, redirect, send_from_directory, url_for, jsonify, make_response +from flask import request, render_template, redirect, send_from_directory, url_for, jsonify from marshmallow import Schema, fields from main import db, app, ma from sqlalchemy import Sequence, text, select, union, or_ @@ -242,6 +242,7 @@ class EntryAmendmentSchema(ma.SQLAlchemyAutoSchema): model = EntryAmendment load_instance = True eid = ma.auto_field() + job_id = ma.auto_field() type = ma.Nested(AmendmentTypeSchema) ################################################################################ @@ -469,7 +470,7 @@ def change_file_opts(): query_data = GetSearchQueryData( OPT ) else: query_data = GetQueryData( OPT ) - return make_response( jsonify( query_data=query_data ) ) + return jsonify( query_data=query_data ) ################################################################################ @@ -655,7 +656,7 @@ def move_files(): jex.append( JobExtra( name=f"{el}", value=str(request.form[el]) ) ) job=NewJob( name="move_files", num_files=0, wait_for=None, jex=jex, desc="to move selected file(s)" ) # data is not used, but send response to trigger CheckForJobs() - return make_response( jsonify( job_id=job.id ) ) + return jsonify( job_id=job.id ) @login_required @app.route("/view/", methods=["POST"]) @@ -697,7 +698,7 @@ def transform(): jex.append( JobExtra( name=f"{el}", value=str(request.form[el]) ) ) job=NewJob( name="transform_image", num_files=0, wait_for=None, jex=jex, desc="to transform selected file(s)" ) - return make_response( jsonify( job_id=job.id ) ) + return jsonify( job_id=job.id ) ################################################################################ # /check_transform_job -> URL that is called repeatedly by front-end waiting for the @@ -714,9 +715,11 @@ def check_transform_job(): j=jsonify( finished=False ) if job.pa_job_state == 'Completed': id=[jex.value for jex in job.extra if jex.name == "id"][0] - e=Entry.query.join(File).filter(Entry.id==id).first() - j=jsonify( finished=True, thumbnail=e.file_details.thumbnail ) - return make_response( j ) + stmt=select(Entry).where(Entry.id==id) + ent=db.session.execute(stmt).scalars().all() + ent_data=entries_schema.dump(ent) + j=jsonify( finished=True, entry=ent_data[0] ) + return j ################################################################################ # /include -> return contents on /include and does not need a login, so we @@ -762,7 +765,7 @@ def get_existing_paths(dt): except: # this is not a date, so we cant work out possible dirs, just # return an empty set - return make_response( '[]' ) + return jsonify( '[]' ) new_dt=new_dtime.strftime('%Y%m%d') # find dirs named with this date dirs_arr+=Dir.query.filter(Dir.rel_path.ilike('%'+new_dt+'%')).all(); @@ -776,8 +779,8 @@ def get_existing_paths(dt): ret='[ ' first_dir=1 for dir in dirs: - # this can occur if there is a file with this date name in the top-levle of the path, its legit, but only really happens in DEV - # regardless, it cant be used for a existpath button in the F/E, ignore it + # this can occur if there is a file with this date name in the top-level of the path, its legit, but only really happens in DEV + # regardless, it cant be used for a existing path button in the F/E, ignore it if dir.rel_path == '': continue if not first_dir: @@ -795,7 +798,7 @@ def get_existing_paths(dt): ret+= ' } ' first_dir=0 ret+= ' ]' - return make_response( ret ) + return jsonify ( ret ) # quick helper func to return timestamps of jscript files # we use this as a quick/hacky way of versioning them