From 2284fd3263b80aa04723a8eea9a1bdb0c7934318 Mon Sep 17 00:00:00 2001 From: gitadmin Date: Thu, 25 Dec 2025 20:59:18 +0300 Subject: [PATCH] =?UTF-8?q?[=D0=92=D0=9E=D0=9B=D0=9A]=20=D1=83=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=83=D0=B1?= =?UTF-8?q?=D0=BB=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D0=B5=D0=B9=20=D0=BF=D0=BB?= =?UTF-8?q?=D0=BE=D1=89=D0=B0=D0=B4=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db_edit.py | 12 +++++++++--- ensure_db.py | 10 ++++++++-- templates/index.html | 39 ++++++++++++++++++++++++++++++++++++--- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/db_edit.py b/db_edit.py index ba23d6c..2a7b8b2 100644 --- a/db_edit.py +++ b/db_edit.py @@ -1100,7 +1100,7 @@ def api_categories(): try: with db.conn.cursor() as cursor: cursor.execute(""" - SELECT AUTO_ID, ID, TITLE, description + SELECT AUTO_ID, ID, TITLE, description, marked_for_publication, is_tg_published FROM categories ORDER BY TITLE, ID """) @@ -1112,7 +1112,9 @@ def api_categories(): 'auto_id': cat['AUTO_ID'], 'id': cat['ID'], 'title': cat['TITLE'] or '', - 'description': cat['description'] or '' + 'description': cat['description'] or '', + 'marked_for_publication': bool(cat['marked_for_publication']) if cat['marked_for_publication'] is not None else False, + 'is_tg_published': bool(cat['is_tg_published']) if cat['is_tg_published'] is not None else False }) return jsonify(categories_list) @@ -1129,7 +1131,7 @@ def api_category_details(category_id): try: with db.conn.cursor() as cursor: cursor.execute(""" - SELECT AUTO_ID, ID, TITLE, description, image_url + SELECT AUTO_ID, ID, TITLE, description, image_url, tg_id, is_tg_published, tg_published_date, marked_for_publication FROM categories WHERE ID = %s """, (category_id,)) @@ -1153,6 +1155,10 @@ def api_category_details(category_id): 'title': category['TITLE'] or '', 'description': category['description'] or '', 'image_url': category['image_url'] or '', + 'tg_id': category['tg_id'], + 'is_tg_published': bool(category['is_tg_published']) if category['is_tg_published'] is not None else False, + 'tg_published_date': category['tg_published_date'].isoformat() if category['tg_published_date'] else None, + 'marked_for_publication': bool(category['marked_for_publication']) if category['marked_for_publication'] is not None else False, 'event_count': event_count }) except Exception as e: diff --git a/ensure_db.py b/ensure_db.py index c85a394..59bfa23 100644 --- a/ensure_db.py +++ b/ensure_db.py @@ -164,7 +164,10 @@ def ensure_database_structure(): TITLE VARCHAR(2048), description TEXT, tg_id BIGINT NULL, - image_url VARCHAR(2048) + image_url VARCHAR(2048), + is_tg_published BOOLEAN DEFAULT 0, + tg_published_date DATETIME NULL, + marked_for_publication BOOLEAN DEFAULT 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 ''' } @@ -228,7 +231,10 @@ def ensure_database_structure(): 'categories': [ {'column': 'description', 'type': 'TEXT'}, {'column': 'tg_id', 'type': 'BIGINT NULL'}, - {'column': 'image_url', 'type': 'VARCHAR(2048)'} + {'column': 'image_url', 'type': 'VARCHAR(2048)'}, + {'column': 'is_tg_published', 'type': 'BOOLEAN DEFAULT 0'}, + {'column': 'tg_published_date', 'type': 'DATETIME NULL'}, + {'column': 'marked_for_publication', 'type': 'BOOLEAN DEFAULT 0'} ], 'events': [ {'column': 'authors', 'type': 'VARCHAR(255)'} diff --git a/templates/index.html b/templates/index.html index 809f87e..1a28e30 100644 --- a/templates/index.html +++ b/templates/index.html @@ -700,6 +700,7 @@ ID Название + Статус @@ -709,7 +710,7 @@ - - @@ -1855,10 +1856,17 @@ } tableBody.innerHTML = ''; categories.forEach(category => { + const publicationBadge = category.marked_for_publication + ? 'Для публикации' + : ''; + const publishedBadge = category.is_tg_published + ? 'Опубликовано' + : ''; const row = ` + `; tableBody.innerHTML += row; }); @@ -1878,7 +1886,7 @@ } catch (error) { tableBody.innerHTML = ` -
+
Загрузка...
@@ -1846,7 +1847,7 @@ if (categories.length === 0) { tableBody.innerHTML = `
+

Нет доступных площадок

${category.id || '-'} ${category.title || 'Без названия'}${publicationBadge}${publishedBadge}
+

Ошибка загрузки данных