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

12 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 WTForms form for settings SeedboxSync.""" 

8 

9from flask_wtf import FlaskForm 

10from wtforms import BooleanField, IntegerField, SelectField 

11from wtforms.validators import InputRequired, NumberRange 

12from seedboxsync.front.babel import ALLOWED_LANGUAGES, gettext as _ 

13 

14 

15class SettingsSeedboxSyncForm(FlaskForm): # type: ignore[misc] 

16 """ 

17 Form for configuring core SeedboxSync preferences. 

18 

19 Provides controls for toggling background synchronization tasks and 

20 customizing WebUI presentation settings (theme and language). 

21 """ 

22 

23 sync_blackhole_enabled = BooleanField(_("Enable the blackhole synchronization task")) 

24 sync_seedbox_enabled = BooleanField(_("Enable the seedbox synchronization task")) 

25 webui_theme = SelectField( 

26 _("Theme of the WebUI"), 

27 choices=[ 

28 ("auto", _("Automatic")), 

29 ("dark", _("Dark")), 

30 ("light", _("Light")), 

31 ], 

32 default="auto", 

33 render_kw={"icon": "fa-sun"}, 

34 ) 

35 webui_language = SelectField( 

36 _("Language of the WebUI"), 

37 choices=[("auto", _("Automatic"))] + [(lang, lang) for lang in ALLOWED_LANGUAGES], 

38 default="auto", 

39 render_kw={"icon": "fa-language"}, 

40 ) 

41 webui_doughnut_legend = SelectField( 

42 _("Doughnut chart legend position"), 

43 choices=[ 

44 ("top", _("Top")), 

45 ("left", _("left")), 

46 ("bottom", _("Bottom")), 

47 ("right", _("Right")), 

48 ("hidden", _("Hidden")), 

49 ], 

50 default="hidden", 

51 render_kw={"icon": "fa-up-down-left-right"}, 

52 ) 

53 webui_doughnut_legend_limit = IntegerField( 

54 _("Maximum number of items in the legend (0 = no limit)"), 

55 validators=[InputRequired(), NumberRange(min=0, max=999)], 

56 render_kw={"placeholder": "0", "icon": "fa-list-ol"}, 

57 ) 

58 wtf_csrf_enabled = BooleanField(_("Enable CSRF protection for all forms?"))