Coverage for seedboxsync/front/views/settings/seedboxsync.py: 100%

19 statements  

« 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 seedboxsync.""" 

8 

9from flask import render_template 

10from seedboxsync.core import current_app 

11from seedboxsync.front.babel import gettext as _ 

12from seedboxsync.front.forms import SettingsSeedboxSyncForm 

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 

16 

17 

18@bp.route("/seedboxsync", methods=("GET", "POST")) 

19@login_required # type: ignore[untyped-decorator] 

20def seedboxsync() -> str: 

21 """ 

22 Render and process the general SeedboxSync settings form. 

23 

24 Handles loading, displaying, and persisting application-wide 

25 configuration choices. 

26 

27 Returns: 

28 str: Rendered HTML template for the main settings page. 

29 """ 

30 form = SettingsSeedboxSyncForm(data=current_app.seedboxsync_config) 

31 

32 if form.validate_on_submit(): 

33 try: 

34 save_settings_form(form) 

35 toast(_("Configuration saved successfully."), _("SeedboxSync"), "success") 

36 except Exception as e: 

37 current_app.logger.exception("Failed to save configuration.", exc_info=e) 

38 toast(_("Failed to save configuration."), _("SeedboxSync"), "danger") 

39 

40 return render_template("settings/seedboxsync.html", form=form)