From 34f339d43471d7285b41abf826af79592711ac48 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 5 Aug 2026 14:45:57 +0500 Subject: [PATCH] Tighten raw rewrite selection UI --- src/vk_parser_app/admin.py | 10 ++++++-- .../templates/raw_posts_content.html | 24 ++++++++++++------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/vk_parser_app/admin.py b/src/vk_parser_app/admin.py index c36e762..be906a6 100644 --- a/src/vk_parser_app/admin.py +++ b/src/vk_parser_app/admin.py @@ -1123,6 +1123,13 @@ def prepare_raw_post(row: Any) -> dict[str, Any]: post["qualified_at_fmt"] = format_dt(post.get("qualified_at")) post["stage"] = pipeline_stage(post) post["ai_badge"] = ai_badge(post) + post["can_send_to_rewrite"] = ( + post.get("status") == "storage_ready" + and ( + (post.get("qualification_status") or "pending") == "rejected" + or (post.get("editorial_status") or "review") == "rejected" + ) + ) return post @@ -2727,8 +2734,7 @@ async def raw_send_to_rewrite( WHERE id=ANY($1::bigint[]) AND status='storage_ready' AND ( - COALESCE(rewrite_status, 'pending') IN ('pending', 'failed') - OR COALESCE(qualification_status, 'pending')='rejected' + COALESCE(qualification_status, 'pending')='rejected' OR COALESCE(editorial_status, 'review')='rejected' ) FOR UPDATE diff --git a/src/vk_parser_app/templates/raw_posts_content.html b/src/vk_parser_app/templates/raw_posts_content.html index 2ecff46..520fb1c 100644 --- a/src/vk_parser_app/templates/raw_posts_content.html +++ b/src/vk_parser_app/templates/raw_posts_content.html @@ -107,7 +107,11 @@ {% for p in posts %}
- + {% if p.can_send_to_rewrite %} + + {% else %} + + {% endif %}
#{{ p.id }}
{{ p.source_name }}
@@ -131,7 +135,7 @@
- {{ p.raw_text }} + {{ p.raw_text }} {% if p.media_items %} @@ -173,19 +177,21 @@ {% for p in posts %} - + {% if p.can_send_to_rewrite %} + + {% endif %} - + #{{ p.id }} - + {{ p.source_name }}
{{ p.source_platform }} #{{ p.source_tag or "—" }}
- +
{{ p.status }} {% if p.qualification_status %} @@ -199,10 +205,10 @@
{{ p.error }}
{% endif %} - +
- {{ p.raw_text }} + {{ p.raw_text }} {% if p.media_items %} @@ -223,7 +229,7 @@
Создан: {{ p.created_at_fmt }}
{% endif %} - + {% if p.qualification_score is not none %}
{{ p.qualification_score }}
{% else %}