diff --git a/aleksis/apps/chronos/preferences.py b/aleksis/apps/chronos/preferences.py index a2bd26ef9eac55d0ddca38091619b3d008279803..8b835c8d1f0a2a723cf53ccd8932d0c39e8847be 100644 --- a/aleksis/apps/chronos/preferences.py +++ b/aleksis/apps/chronos/preferences.py @@ -122,3 +122,25 @@ class SupervisionEventFeedColor(StringPreference): verbose_name = _("Supervision calendar feed color") widget = ColorWidget required = True + +@site_preferences_registry.register +class DaysInCalendar(MultipleChoicePreference): + section = chronos + name = "days_in_calendar" + default = ["1", "2", "3", "4", "5"] + verbose_name = _("Days of the week that appear in the timetable") + choices = [ + ("1", _("Monday")), + ("2", _("Tuesday")), + ("3", _("Wednesday")), + ("4", _("Thursday")), + ("5", _("Friday")), + ("6", _("Saturday")), + ("0", _("Sunday")), + ] + required = True + + def validate(self, value): + for v in value: + if int(v) not in self.get_choice_values(): + raise ValidationError(f"{v} is not a valid choice")