Added revised book feature.
This commit is contained in:
@@ -887,6 +887,34 @@ def restart_run(id):
|
||||
flash(f"Started new Run #{new_run.id}" + (" with modifications." if feedback else "."))
|
||||
return redirect(url_for('view_project', id=run.project_id))
|
||||
|
||||
@app.route('/project/<int:run_id>/revise_book/<string:book_folder>', methods=['POST'])
|
||||
@login_required
|
||||
def revise_book(run_id, book_folder):
|
||||
run = db.session.get(Run, run_id) or Run.query.get_or_404(run_id)
|
||||
if run.project.user_id != current_user.id: return "Unauthorized", 403
|
||||
|
||||
instruction = request.form.get('instruction')
|
||||
|
||||
# Create new run
|
||||
new_run = Run(project_id=run.project_id, status="queued")
|
||||
db.session.add(new_run)
|
||||
db.session.commit()
|
||||
|
||||
# Task: Apply feedback to Bible, Copy all books EXCEPT this one, then Generate
|
||||
task = generate_book_task(
|
||||
new_run.id,
|
||||
run.project.folder_path,
|
||||
os.path.join(run.project.folder_path, "bible.json"),
|
||||
allow_copy=True,
|
||||
feedback=instruction,
|
||||
source_run_id=run.id,
|
||||
keep_cover=True,
|
||||
exclude_folders=[book_folder]
|
||||
)
|
||||
|
||||
flash(f"Started Revision Run #{new_run.id}. Book '{book_folder}' will be regenerated.")
|
||||
return redirect(url_for('view_project', id=run.project_id))
|
||||
|
||||
@app.route('/run/<int:id>')
|
||||
@login_required
|
||||
def view_run(id):
|
||||
|
||||
Reference in New Issue
Block a user