diff --git a/fuenfvoacht/src/app.py b/fuenfvoacht/src/app.py index 8da687f1..d8dd833b 100644 --- a/fuenfvoacht/src/app.py +++ b/fuenfvoacht/src/app.py @@ -356,7 +356,8 @@ def api_save(date_str): flog.article_saved(date_str, post_time) return jsonify({'success': True, 'article_id': existing['id']}) all_today = db.get_articles_by_date(date_str) - candidate = next((a for a in all_today if a['status'] in ('draft', 'scheduled', 'sent_to_bot', 'approved', 'pending_review')), None) + draft = next((a for a in all_today if a['status'] == 'draft'), None) + candidate = draft or next((a for a in all_today if a['status'] in ('pending_review', 'scheduled', 'sent_to_bot')), None) if candidate: old_time = candidate['post_time'] conn = db.get_conn() diff --git a/fuenfvoacht/src/templates/index.html b/fuenfvoacht/src/templates/index.html index 34d136af..506eee6b 100644 --- a/fuenfvoacht/src/templates/index.html +++ b/fuenfvoacht/src/templates/index.html @@ -715,16 +715,18 @@ async function confirmPlan() { btn.disabled = true; try { - // 1. Speichern auf selectedDate (dort liegt der generierte Artikel) + const currentTime = document.getElementById('post-time-input')?.value || '19:55'; + + // 1. Speichern auf selectedDate mit der AKTUELLEN post_time (nicht Ziel-Zeit) const saveRes = await fetch(`/api/article/${selectedDate}/save`, { method: 'POST', headers: {'Content-Type':'application/json'}, - body: JSON.stringify({content, post_time: time}) + body: JSON.stringify({content, post_time: currentTime}) }); const saveData = await saveRes.json(); if (!saveData.success) throw new Error(saveData.error || 'Speichern fehlgeschlagen'); - // 2. Falls Zieldatum != Quelldatum: Artikel verschieben - if (date !== selectedDate && saveData.article_id) { + // 2. Artikel auf Zieldatum+Zeit verschieben (auch wenn gleiches Datum, andere Zeit) + if (saveData.article_id && (date !== selectedDate || time !== currentTime)) { const reRes = await fetch(`/api/article/${saveData.article_id}/reschedule`, { method: 'POST', headers: {'Content-Type':'application/json'}, body: JSON.stringify({date, post_time: time})