Coverage for seedboxsync/front/views/settings/seedbox.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 seedbox.""" 

8 

9from flask import render_template 

10from seedboxsync.core import current_app 

11from seedboxsync.front.babel import gettext as _ 

12from seedboxsync.front.forms import SettingsSeedboxForm 

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("/seedbox", methods=("GET", "POST")) 

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

20def seedbox() -> str: 

21 """ 

22 Render and process the Seedbox connection settings form. 

23 

24 Manages settings related to remote Seedbox access, timeouts, 

25 and file permission overrides. 

26 

27 Returns: 

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

29 """ 

30 form = SettingsSeedboxForm(data=current_app.seedboxsync_config) 

31 

32 if form.validate_on_submit(): 

33 try: 

34 save_settings_form(form) 

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

36 except Exception as e: 

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

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

39 

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