diff --git a/aleksis/core/managers.py b/aleksis/core/managers.py index fccc79daae0e5267ef7912a8ae62850dc00c2a20..3e9d4405163ef37967c0aabae4793a3255f8a1c9 100644 --- a/aleksis/core/managers.py +++ b/aleksis/core/managers.py @@ -47,12 +47,20 @@ class PolymorphicBaseManager(AlekSISBaseManagerWithoutMigrations, PolymorphicMan """Default manager for extensible, polymorphic models.""" -class RecurrencePolymorphicQuerySet(PolymorphicQuerySet, CTEQuerySet): +class CalendarEventMixinQuerySet(CTEQuerySet): pass -class RecurrencePolymorphicManager(PolymorphicBaseManager, RecurrenceManager): - queryset_class = RecurrencePolymorphicQuerySet +class CalendarEventQuerySet(CalendarEventMixinQuerySet, PolymorphicQuerySet): + pass + + +class CalendarEventMixinManager(RecurrenceManager): + queryset_class = CalendarEventQuerySet + + +class CalendarEventManager(CalendarEventMixinManager, PolymorphicBaseManager): + queryset_class = CalendarEventMixinQuerySet class DateRangeQuerySetMixin: @@ -211,7 +219,7 @@ class InstalledWidgetsDashboardWidgetOrderManager(Manager): return super().get_queryset().filter(widget_id__in=dashboard_widget_pks) -class HolidayQuerySet(DateRangeQuerySetMixin, RecurrencePolymorphicQuerySet): +class HolidayQuerySet(DateRangeQuerySetMixin, CalendarEventQuerySet): """QuerySet with custom query methods for holidays.""" def get_all_days(self) -> list[date]: @@ -222,5 +230,5 @@ class HolidayQuerySet(DateRangeQuerySetMixin, RecurrencePolymorphicQuerySet): return holiday_days -class HolidayManager(RecurrencePolymorphicManager): +class HolidayManager(CalendarEventManager): queryset_class = HolidayQuerySet diff --git a/aleksis/core/models.py b/aleksis/core/models.py index e27a4709e488e19b19a4f5cdc9b6115cad4de4c0..d6d1b1041087033b8b2905f55d0956ee390d4e3b 100644 --- a/aleksis/core/models.py +++ b/aleksis/core/models.py @@ -62,13 +62,14 @@ from aleksis.core.data_checks import ( from .managers import ( AlekSISBaseManagerWithoutMigrations, + CalendarEventManager, + CalendarEventMixinManager, GroupManager, GroupQuerySet, HolidayManager, InstalledWidgetsDashboardWidgetOrderManager, PersonManager, PersonQuerySet, - RecurrencePolymorphicManager, SchoolTermQuerySet, UninstallRenitentPolymorphicManager, ) @@ -1632,7 +1633,7 @@ class CalendarEvent( Please refer to the documentation of `CalendarEventMixin` for more information. """ - objects = RecurrencePolymorphicManager() + objects = CalendarEventManager() datetime_start = models.DateTimeField( verbose_name=_("Start date and time"), null=True, blank=True @@ -1872,6 +1873,15 @@ class BirthdayEvent(CalendarEventMixin, models.Model): person = models.ForeignKey(Person, on_delete=models.DO_NOTHING) + objects = CalendarEventMixinManager() + + class Meta: + managed = False + db_table = "core_birthdayevent" + + def __str__(self): + return self.value_title(self) + @classmethod def value_title( cls, reference_object: "BirthdayEvent", request: HttpRequest | None = None @@ -1939,10 +1949,6 @@ class BirthdayEvent(CalendarEventMixin, models.Model): ) return BirthdayEvent.objects.filter(person__in=qs) - class Meta: - managed = False - db_table = "core_birthdayevent" - class Holiday(CalendarEvent): """Holiday model for keeping track of school holidays."""