Replace video_warning with target_type + has_videos/has_photos
All checks were successful
Validate / Hassfest (push) Successful in 2s

Major template system improvements:
- Remove video_warning field from TemplateConfig model
- Add target_type, has_videos, has_photos to template context
- Templates use {% if target_type == "telegram" and has_videos %}
  for conditional Telegram warnings instead of a separate field
- date_format moved from "Telegram" to "Settings" group
- Add target type selector (Telegram/Webhook) in template editor
  to preview how templates render for each target type
- All template slots now use JinjaEditor (not plain <input>)
- Preview endpoint accepts target_type parameter
- Clean up TemplateConfigCreate schema (remove stale fields)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-19 21:11:38 +03:00
parent 510463cba6
commit 4babaddd87
9 changed files with 66 additions and 49 deletions

View File

@@ -135,9 +135,6 @@ class TemplateConfig(SQLModel, table=True):
# Settings
date_format: str = Field(default="%d.%m.%Y, %H:%M UTC")
video_warning: str = Field(
default="⚠️ Note: Videos may not be sent due to Telegram's 50 MB file size limit."
)
created_at: datetime = Field(default_factory=_utcnow)
@@ -204,7 +201,9 @@ _INLINE_TEMPLATES_REMOVED = {
'{%- if asset.is_favorite %} ❤️{% endif %}\n'
'{%- endfor %}'
'{%- endif %}'
'{%- if video_warning %}\n\n{{ video_warning }}{%- endif %}'
'{%- if target_type == "telegram" and has_videos %}\n\n'
'⚠️ Videos may not be sent due to Telegram\'s 50 MB file size limit.'
'{%- endif %}'
),
"message_assets_removed": '🗑️ {{ removed_count }} photo(s) removed from album "{{ album_name }}".',
@@ -254,7 +253,9 @@ DEFAULT_TEMPLATE_RU = {
'{%- if asset.is_favorite %} ❤️{% endif %}\n'
'{%- endfor %}'
'{%- endif %}'
'{%- if video_warning %}\n\n{{ video_warning }}{%- endif %}'
'{%- if target_type == "telegram" and has_videos %}\n\n'
'⚠️ Видео может не отправиться из-за ограничения Telegram в 50 МБ.'
'{%- endif %}'
),
"message_assets_removed": '🗑️ {{ removed_count }} фото удалено из альбома "{{ album_name }}".',