Coverage for seedboxsync/front/views/settings/ping.py: 100%
19 statements
« prev ^ index » next coverage.py v7.16.1, created at 2026-09-26 17:14 +0000
« prev ^ index » next coverage.py v7.16.1, created at 2026-09-26 17:14 +0000
1#
2# Copyright (C) 2015-2026 Guillaume Kulakowski <guillaume@kulakowski.fr>
3#
4# For the full copyright and license information, please view the LICENSE
5# file that was distributed with this source code.
6#
7"""SeedboxSync Flask view for settings pings services."""
9from flask import render_template
10from seedboxsync.core import current_app
11from seedboxsync.front.babel import gettext as _
12from seedboxsync.front.forms import SettingsPingForm
13from seedboxsync.front.login_manager import login_required
14from seedboxsync.front.utils import save_settings_form, toast
15from seedboxsync.front.views import bp_settings as bp
18@bp.route("/ping", methods=("GET", "POST"))
19@login_required # type: ignore[untyped-decorator]
20def ping() -> str:
21 """
22 Render and process the ping/connectivity notification settings form.
24 Configures heartbeat signals and external notification endpoints.
26 Returns:
27 str: Rendered HTML template for the Ping settings page.
28 """
29 form = SettingsPingForm(data=current_app.seedboxsync_config)
31 if form.validate_on_submit():
32 try:
33 save_settings_form(form)
34 toast(_("Configuration saved successfully."), _("Ping"), "success")
35 except Exception as e:
36 current_app.logger.exception("Failed to save configuration.", exc_info=e)
37 toast(_("Failed to save configuration."), _("Ping"), "danger")
39 return render_template("settings/ping.html", form=form)