diff --git a/app_new/logs/routes.py b/app_new/logs/routes.py index c74b92a..86513bd 100644 --- a/app_new/logs/routes.py +++ b/app_new/logs/routes.py @@ -1,8 +1,10 @@ """Logs centralises des watchdogs.""" -from flask import Blueprint, render_template, request, jsonify +from flask import Blueprint, render_template, request, jsonify, flash, redirect, url_for from flask_login import login_required +from sqlalchemy import text from app_new.extensions import db from app_new.core.models.maintenance import WatchdogLog +from app_new.core.system_security import system_admin_required logs_bp = Blueprint('logs', __name__, url_prefix='/logs', template_folder='templates') @@ -57,3 +59,13 @@ def api_recent(): 'message': log.message, 'created_at': log.created_at.isoformat() if log.created_at else None } for log in logs]) + + +@logs_bp.route('/clear', methods=['POST']) +@system_admin_required +def clear_watchdog_logs(): + """Vide integralement la table dediee aux journaux des watchdogs.""" + db.session.execute(text('TRUNCATE TABLE watchdog_logs')) + db.session.commit() + flash('Les journaux des watchdogs ont été vidés.', 'success') + return redirect(url_for('logs.index')) diff --git a/app_new/logs/templates/logs/index.html b/app_new/logs/templates/logs/index.html index 7fe5942..e9fcbea 100644 --- a/app_new/logs/templates/logs/index.html +++ b/app_new/logs/templates/logs/index.html @@ -4,7 +4,17 @@ {% block content %}