fixxes over codex
This commit is contained in:
+10
-6
@@ -1,11 +1,15 @@
|
||||
# app/routes/admin.py
|
||||
import datetime
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
from datetime import datetime
|
||||
|
||||
from flask import Blueprint, render_template, request, jsonify, redirect, url_for
|
||||
from flask import Blueprint, render_template, request, jsonify, redirect, url_for, current_app
|
||||
from app.state import current_config
|
||||
from app.utils.helpers import load_configs, load_default_sounds
|
||||
|
||||
admin_bp = Blueprint('admin', __name__)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@admin_bp.route('/')
|
||||
def admin():
|
||||
@@ -15,7 +19,7 @@ def admin():
|
||||
|
||||
@admin_bp.route('/edit/<filename>', methods=['GET', 'POST'])
|
||||
def admin_edit_config(filename):
|
||||
path = os.path.join(app.config['CONFIG_DIR'], filename)
|
||||
path = os.path.join(current_app.config['CONFIG_DIR'], filename)
|
||||
|
||||
if request.method == 'POST':
|
||||
try:
|
||||
@@ -56,7 +60,7 @@ def admin_edit_config(filename):
|
||||
|
||||
@admin_bp.route('/delete/<filename>', methods=['POST'])
|
||||
def admin_delete_config(filename):
|
||||
path = os.path.join(app.config['CONFIG_DIR'], filename)
|
||||
path = os.path.join(current_app.config['CONFIG_DIR'], filename)
|
||||
if os.path.exists(path):
|
||||
try:
|
||||
os.remove(path)
|
||||
@@ -77,7 +81,7 @@ def admin_logs(date=None):
|
||||
today = datetime.now().strftime('%Y-%m') # ← Hier definieren!
|
||||
current_month = datetime.now().strftime('%Y-%m')
|
||||
|
||||
log_dir = os.path.join(LOG_DIR, today)
|
||||
log_dir = os.path.join(current_app.config['LOG_DIR'], today)
|
||||
|
||||
if not os.path.exists(log_dir):
|
||||
return render_template('admin_logs.html', logs="Keine Logs für diesen Tag.", date=date, dates=[], today=today)
|
||||
@@ -107,4 +111,4 @@ def admin_logs(date=None):
|
||||
date=date,
|
||||
dates=dates,
|
||||
today=current_month)
|
||||
pass
|
||||
pass
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
@main_bp.route('/')
|
||||
def index():
|
||||
configs = load_configs()
|
||||
configs = load_configs(current_app.config['CONFIG_DIR'])
|
||||
return render_template('index.html', configs=configs)
|
||||
|
||||
"""
|
||||
@@ -67,7 +67,7 @@ def control_page():
|
||||
return redirect(url_for('main.index'))
|
||||
|
||||
# Globale Sounds immer laden
|
||||
global_sounds = load_default_sounds()
|
||||
global_sounds = load_default_sounds(current_app.config['CONFIG_DIR'])
|
||||
|
||||
logger.info(f"Steuerseite geladen für Config: {current_config.get('filename', 'unbekannt')} mit {len(current_config.get('channels', []))} Kanälen")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user