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 @@
| + |
Загрузка...
@@ -1846,7 +1847,7 @@
if (categories.length === 0) {
tableBody.innerHTML = `
| |||
| + |
Нет доступных площадок |
@@ -1855,10 +1856,17 @@
}
tableBody.innerHTML = '';
categories.forEach(category => {
+ const publicationBadge = category.marked_for_publication
+ ? 'Для публикации'
+ : '';
+ const publishedBadge = category.is_tg_published
+ ? 'Опубликовано'
+ : '';
const row = `
|||
| ${category.id || '-'} | ${category.title || 'Без названия'} | +${publicationBadge}${publishedBadge} | ||
| + |
Ошибка загрузки данных | |||