Add bible download route and UI button for run details
- New GET /run/<id>/download_bible route serves project bible.json as attachment - Download Bible button added to run_details.html header toolbar Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
<button class="btn btn-outline-primary me-2" type="button" data-bs-toggle="collapse" data-bs-target="#bibleCollapse" aria-expanded="false" aria-controls="bibleCollapse">
|
||||
<i class="fas fa-scroll me-2"></i>Show Bible
|
||||
</button>
|
||||
<a href="{{ url_for('run.download_bible', id=run.id) }}" class="btn btn-outline-info me-2" title="Download the project bible (JSON) used for this run.">
|
||||
<i class="fas fa-file-download me-2"></i>Download Bible
|
||||
</a>
|
||||
<button class="btn btn-primary me-2" data-bs-toggle="modal" data-bs-target="#modifyRunModal" data-bs-toggle="tooltip" title="Create a new run based on this one, but with different instructions (e.g. 'Make it darker').">
|
||||
<i class="fas fa-pen-fancy me-2"></i>Modify & Re-run
|
||||
</button>
|
||||
|
||||
@@ -393,6 +393,27 @@ def revise_book(run_id, book_folder):
|
||||
return redirect(url_for('run.view_run', id=new_run.id))
|
||||
|
||||
|
||||
@run_bp.route('/run/<int:id>/download_bible')
|
||||
@login_required
|
||||
def download_bible(id):
|
||||
run = db.session.get(Run, id)
|
||||
if not run: return "Run not found", 404
|
||||
if run.project.user_id != current_user.id: return "Unauthorized", 403
|
||||
|
||||
bible_path = os.path.join(run.project.folder_path, "bible.json")
|
||||
if not os.path.exists(bible_path):
|
||||
return "Bible file not found", 404
|
||||
|
||||
safe_name = utils.sanitize_filename(run.project.name or "project")
|
||||
download_name = f"bible_{safe_name}.json"
|
||||
return send_from_directory(
|
||||
os.path.dirname(bible_path),
|
||||
os.path.basename(bible_path),
|
||||
as_attachment=True,
|
||||
download_name=download_name
|
||||
)
|
||||
|
||||
|
||||
@run_bp.route('/project/<int:run_id>/regenerate_artifacts', methods=['POST'])
|
||||
@login_required
|
||||
def regenerate_artifacts(run_id):
|
||||
|
||||
Reference in New Issue
Block a user