fix: update regenerate route to use image_paths for mosaic cover
Made-with: Cursor
This commit is contained in:
@@ -3,7 +3,7 @@ import json
|
||||
from flask import Blueprint, render_template, send_file, redirect, url_for, flash
|
||||
|
||||
from app import db
|
||||
from src.models import Issue, Article
|
||||
from src.models import Issue, Article, Image
|
||||
from src.cover import generate_cover
|
||||
from src.epub_builder import build_epub
|
||||
import config
|
||||
@@ -112,14 +112,22 @@ def regenerate(issue_id):
|
||||
a.title for a in articles_for_issue
|
||||
if "Obituaries" not in json.loads(a.categories)
|
||||
]
|
||||
categories_list = []
|
||||
|
||||
image_paths = []
|
||||
for a in articles_for_issue:
|
||||
categories_list.extend(json.loads(a.categories))
|
||||
first_image = Image.query.filter_by(article_id=a.id).first()
|
||||
if first_image:
|
||||
image_paths.append(first_image.local_path)
|
||||
|
||||
cover_method = issue.cover_method
|
||||
if cover_method == "ai":
|
||||
issue.cover_method = "mosaic"
|
||||
cover_method = "mosaic"
|
||||
|
||||
try:
|
||||
cover_path = generate_cover(
|
||||
issue.cover_method, config.ISSUES_DIR,
|
||||
issue.week_start, issue.week_end, headlines, categories_list
|
||||
cover_method, config.ISSUES_DIR,
|
||||
issue.week_start, issue.week_end, headlines, image_paths
|
||||
)
|
||||
epub_path = build_epub(
|
||||
issue.week_start, issue.week_end, article_ids,
|
||||
|
||||
Reference in New Issue
Block a user