fix in u
This commit is contained in:
@@ -2,6 +2,7 @@ from __future__ import annotations
|
||||
|
||||
from flask import Blueprint, jsonify, request
|
||||
|
||||
from ._shared import request_profile
|
||||
from ..services import preferences, download_planner, poller_control
|
||||
from ..services.auth import current_user_id
|
||||
|
||||
|
||||
@@ -218,6 +218,22 @@ def ratio_groups_save():
|
||||
|
||||
|
||||
|
||||
@bp.delete("/ratio-groups/<int:group_id>")
|
||||
def ratio_groups_delete(group_id: int):
|
||||
profile = request_profile()
|
||||
if not profile:
|
||||
return jsonify({"ok": False, "error": "No profile"}), 400
|
||||
if not auth.can_write_profile(int(profile["id"]), default_user_id()):
|
||||
return jsonify({"ok": False, "error": "No write access to profile"}), 403
|
||||
with connect() as conn:
|
||||
# Note: Deleting a ratio group removes only the group definition and its assignment links; history stays as an audit trail.
|
||||
deleted = conn.execute("DELETE FROM ratio_groups WHERE id=? AND profile_id=?", (int(group_id), int(profile["id"]))).rowcount
|
||||
conn.execute("DELETE FROM ratio_assignments WHERE group_id=? AND profile_id=?", (int(group_id), int(profile["id"])))
|
||||
if not deleted:
|
||||
return jsonify({"ok": False, "error": "Ratio group not found"}), 404
|
||||
return ratio_groups_list()
|
||||
|
||||
|
||||
@bp.post("/ratio-groups/check")
|
||||
def ratio_groups_check():
|
||||
profile = request_profile()
|
||||
|
||||
@@ -120,6 +120,12 @@ def app_status():
|
||||
status["speed_peaks"] = speed_peaks.current(profile["id"])
|
||||
except Exception as exc:
|
||||
status["speed_peaks"] = {"error": str(exc)}
|
||||
try:
|
||||
# Note: App status carries poller settings and runtime so the panel still renders when the separate poller endpoint is unavailable.
|
||||
poller_settings = poller_control.get_settings(int(profile["id"]))
|
||||
status["poller"] = {"settings": poller_settings, "runtime": poller_control.snapshot(int(profile["id"]), poller_settings)}
|
||||
except Exception as exc:
|
||||
status["poller"] = {"settings": {}, "runtime": {}, "error": str(exc)}
|
||||
try:
|
||||
prefs = preferences.get_preferences()
|
||||
status["port_check"] = {"status": "disabled", "enabled": False} if not bool((prefs or {}).get("port_check_enabled")) else port_check_status(force=False)
|
||||
|
||||
Reference in New Issue
Block a user