From 1cda8969db6030918a03aa22728f25fb6751a343 Mon Sep 17 00:00:00 2001 From: gitadmin Date: Thu, 25 Dec 2025 22:31:50 +0300 Subject: [PATCH] =?UTF-8?q?[=D0=92=D0=9E=D0=9B=D0=9A]=20=D0=BE=D1=82=D0=BC?= =?UTF-8?q?=D0=B5=D1=82=D0=BA=D0=B0=20=D0=B2=D1=81=D0=B5=D1=85=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D0=B8=D1=81=D0=B5=D0=B9=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=BF=D1=83=D0=B1=D0=BB=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db_edit.py | 66 +++++++++++++++++++++++++++ templates/index.html | 104 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 169 insertions(+), 1 deletion(-) diff --git a/db_edit.py b/db_edit.py index cb4e6c2..df04c28 100644 --- a/db_edit.py +++ b/db_edit.py @@ -677,6 +677,28 @@ def api_toggle_event_publication(event_id): finally: db.close() +@bp.route('/api/events/mark_all_for_publication', methods=['POST']) +@login_required +def api_mark_all_events_for_publication(): + """Отмечает все события для публикации""" + db = get_db() + try: + with db.conn.cursor() as cursor: + cursor.execute(""" + UPDATE events + SET marked_to_publication = 1 + WHERE marked_to_publication = 0 + """) + count = cursor.rowcount + db.conn.commit() + client_ip = get_client_ip() + log_event(f"Отмечено для публикации: {count} событий, IP {client_ip}") + return jsonify({'success': True, 'count': count}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}), 500 + finally: + db.close() + @bp.route('/api/events', methods=['POST']) @login_required def api_add_event(): @@ -804,6 +826,28 @@ def api_toggle_publication(post_id): finally: db.close() +@bp.route('/api/posts/mark_all_for_publication', methods=['POST']) +@login_required +def api_mark_all_posts_for_publication(): + """Отмечает все посты для публикации""" + db = get_db() + try: + with db.conn.cursor() as cursor: + cursor.execute(""" + UPDATE posts + SET marked_to_publication = 1 + WHERE marked_to_publication = 0 + """) + count = cursor.rowcount + db.conn.commit() + client_ip = get_client_ip() + log_event(f"Отмечено для публикации: {count} постов, IP {client_ip}") + return jsonify({'success': True, 'count': count}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}), 500 + finally: + db.close() + @bp.route('/api/posts', methods=['POST']) @login_required def api_add_post(): @@ -1408,6 +1452,28 @@ def api_toggle_category_publication(category_id): finally: db.close() +@bp.route('/api/categories/mark_all_for_publication', methods=['POST']) +@login_required +def api_mark_all_categories_for_publication(): + """Отмечает все категории для публикации""" + db = get_db() + try: + with db.conn.cursor() as cursor: + cursor.execute(""" + UPDATE categories + SET marked_for_publication = 1 + WHERE marked_for_publication = 0 + """) + count = cursor.rowcount + db.conn.commit() + client_ip = get_client_ip() + log_event(f"Отмечено для публикации: {count} площадок, IP {client_ip}") + return jsonify({'success': True, 'count': count}) + except Exception as e: + return jsonify({'success': False, 'error': str(e)}), 500 + finally: + db.close() + @bp.route('/api/categories//events_count') @login_required def api_category_events_count(category_id): diff --git a/templates/index.html b/templates/index.html index 88eead9..9715aec 100644 --- a/templates/index.html +++ b/templates/index.html @@ -469,8 +469,11 @@ + {% endif %} + @@ -668,6 +674,9 @@
+ @@ -927,6 +936,7 @@ loadPosts(); // Добавляем обработчики для кнопок запуска скриптов document.getElementById('rescan-btn').addEventListener('click', runRescanScript); + document.getElementById('mark-all-posts-pub-btn').addEventListener('click', markAllPostsForPublication); document.getElementById('publish-btn').addEventListener('click', runPublishScript); document.getElementById('generate-names-btn').addEventListener('click', generateAllShortnames); document.getElementById('refresh-events-btn').addEventListener('click', loadEvents); @@ -1008,8 +1018,13 @@ zkRescanBtn.addEventListener('click', runZkRescan); } {% endif %} + document.getElementById('mark-all-events-pub-btn').addEventListener('click', markAllEventsForPublication); document.getElementById('publish-all-events-btn').addEventListener('click', publishAllEvents); {% if g.workmode == 'VOLK' %} + const markAllCategoriesPubBtn = document.getElementById('mark-all-categories-pub-btn'); + if (markAllCategoriesPubBtn) { + markAllCategoriesPubBtn.addEventListener('click', markAllCategoriesForPublication); + } const publishAllCategoriesBtn = document.getElementById('publish-all-categories-btn'); if (publishAllCategoriesBtn) { publishAllCategoriesBtn.addEventListener('click', publishAllCategories); @@ -1164,6 +1179,64 @@ alert('Произошла ошибка при рескане ВОЛК'); }); } + // Отметить все посты для публикации + function markAllPostsForPublication() { + if (!confirm('Вы уверены, что хотите отметить все посты для публикации?')) { + return; + } + showProcessingMessage("Отметка всех постов для публикации..."); + fetch(`${PREFIX}/api/posts/mark_all_for_publication`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-Requested-With': 'XMLHttpRequest' + } + }) + .then(response => response.json()) + .then(data => { + hideProcessingMessage(); + if (data.success) { + alert(`Отмечено для публикации: ${data.count || 0} постов`); + loadPosts(); + } else { + alert('Ошибка: ' + (data.error || 'неизвестная ошибка')); + } + }) + .catch(error => { + hideProcessingMessage(); + console.error('Ошибка:', error); + alert('Произошла ошибка при отметке постов'); + }); + } + // Отметить все события для публикации + function markAllEventsForPublication() { + if (!confirm('Вы уверены, что хотите отметить все события для публикации?')) { + return; + } + showProcessingMessage("Отметка всех событий для публикации..."); + fetch(`${PREFIX}/api/events/mark_all_for_publication`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-Requested-With': 'XMLHttpRequest' + } + }) + .then(response => response.json()) + .then(data => { + hideProcessingMessage(); + if (data.success) { + alert(`Отмечено для публикации: ${data.count || 0} событий`); + loadEvents(); + } else { + alert('Ошибка: ' + (data.error || 'неизвестная ошибка')); + } + }) + .catch(error => { + hideProcessingMessage(); + console.error('Ошибка:', error); + alert('Произошла ошибка при отметке событий'); + }); + } // Функция для публикации всех событий function publishAllEvents() { const currentEventId = selectedEventId; @@ -2272,6 +2345,35 @@ alert('Произошла ошибка при публикации площадки'); } } + // Отметить все категории для публикации + function markAllCategoriesForPublication() { + if (!confirm('Вы уверены, что хотите отметить все площадки для публикации?')) { + return; + } + showProcessingMessage("Отметка всех площадок для публикации..."); + fetch(`${PREFIX}/api/categories/mark_all_for_publication`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'X-Requested-With': 'XMLHttpRequest' + } + }) + .then(response => response.json()) + .then(data => { + hideProcessingMessage(); + if (data.success) { + alert(`Отмечено для публикации: ${data.count || 0} площадок`); + loadCategoriesList(); + } else { + alert('Ошибка: ' + (data.error || 'неизвестная ошибка')); + } + }) + .catch(error => { + hideProcessingMessage(); + console.error('Ошибка:', error); + alert('Произошла ошибка при отметке площадок'); + }); + } // Публикация всех категорий function publishAllCategories() { const currentCategoryId = selectedCategoryId;