diff --git a/db_edit.py b/db_edit.py index 2922f1b..521ef5e 100644 --- a/db_edit.py +++ b/db_edit.py @@ -24,6 +24,7 @@ from tg_publish import publish_to_tg_all, publish_to_tg from db_update_shortname import ai_shortname_all, generate_ai_shortname from evtg_publish import tg_post_event_by_id, tg_post_all_events from zk_load import load_json_all +from volk_load import load_categories # Загружаем настройки из .env load_dotenv() @@ -1064,6 +1065,26 @@ def api_publish_all_events(): log_event(error_msg) return jsonify({'success': False, 'error': error_msg}), 500 +@bp.route('/api/load_categories', methods=['POST']) +@login_required +def api_load_categories(): + try: + # Проверка режима работы + workmode = os.getenv('WORKMODE', 'ZILANT') + if workmode != 'VOLK': + error_msg = "Загрузка категорий доступна только в режиме VOLK" + log_event(error_msg) + return jsonify({'success': False, 'error': error_msg}), 403 + + log_event("Запуск загрузки категорий...") + load_categories() + log_event("Загрузка категорий выполнена успешно") + return jsonify({'success': True}) + except Exception as e: + error_msg = f"Ошибка при загрузке категорий: {str(e)}" + log_event(error_msg) + return jsonify({'success': False, 'error': error_msg}), 500 + @bp.route('/api/publish_event/', methods=['POST']) @login_required def api_publish_event(event_id): diff --git a/templates/index.html b/templates/index.html index e951de0..ef7ba43 100644 --- a/templates/index.html +++ b/templates/index.html @@ -566,6 +566,11 @@ + {% if g.workmode == 'VOLK' %} + + {% endif %}