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

13 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-11 07:37 +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_stats_bar_y_limit = IntegerField( 

42 _("Maximum number of items in vertical bar (0 = no limit)"), 

43 validators=[InputRequired(), NumberRange(min=0, max=99)], 

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

45 ) 

46 webui_dashboard_refresh = IntegerField( 

47 _("Dashboard refresh interval (in seconds)"), 

48 validators=[InputRequired(), NumberRange(min=30, max=300)], 

49 render_kw={"placeholder": "60", "icon": "fa-rotate"}, 

50 ) 

51 webui_dashboard_nb_elements = IntegerField( 

52 _("Max dashboard items"), 

53 validators=[InputRequired(), NumberRange(min=3, max=100)], 

54 render_kw={"placeholder": "5", "icon": "fa-cubes"}, 

55 ) 

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