diff --git a/aleksis/apps/lesrooster/models.py b/aleksis/apps/lesrooster/models.py index b18d01773f1860931b82f3ea8680f0ca1fba00a2..9525137be45549e57dabccfef74b6a9600cae5ce 100644 --- a/aleksis/apps/lesrooster/models.py +++ b/aleksis/apps/lesrooster/models.py @@ -480,7 +480,8 @@ class LessonBundle(ExtensibleModel): ) lesson_bundle.lessons.set( - [Lesson.create_from_course(course, validity_range) for course in course_bundle.courses.all()] + [Lesson.create_from_course(course, validity_range) + for course in course_bundle.courses.all()] ) return lesson_bundle @@ -552,7 +553,7 @@ class Lesson(TeacherPropertiesMixin, RoomPropertiesMixin, ExtensibleModel): def create_from_course(cls, course: Course, validity_range: ValidityRange) -> "Lesson": """Create a lesson from a course backed by a validity range.""" # Lookup the TCC for the course in the validity_range - tcc = TimeboundCourseConfig.objects.managed_and_unmanaged().get( + tcc = TimeboundCourseConfig.objects.get( course=course, validity_range=validity_range ) lesson = cls.objects.create( diff --git a/aleksis/apps/lesrooster/preferences.py b/aleksis/apps/lesrooster/preferences.py index 92705561de93da1fee0c5bd48e3b52526c047e77..718017e3d588d4ce4a2485a3ca6f5e4ed1bbdef6 100644 --- a/aleksis/apps/lesrooster/preferences.py +++ b/aleksis/apps/lesrooster/preferences.py @@ -33,9 +33,6 @@ class GroupTypeCourseGroups(ModelChoicePreference): verbose_name = _("Group type for automatically created course groups") help_text = _("If you leave it empty, no group type will be used.") - def get_queryset(self): - return GroupType.objects.managed_and_unmanaged() - @site_preferences_registry.register class FillCourseGroupsWithMembers(BooleanPreference): diff --git a/aleksis/apps/lesrooster/schema/__init__.py b/aleksis/apps/lesrooster/schema/__init__.py index 3c37400bb36c53e59db51e7e678f20544d0bbb6b..4445ee51d9dcc347d21801b059d621da29432768 100644 --- a/aleksis/apps/lesrooster/schema/__init__.py +++ b/aleksis/apps/lesrooster/schema/__init__.py @@ -249,7 +249,7 @@ class Query(graphene.ObjectType): return [] return graphene_django_optimizer.query( - CourseBundle.objects.managed_and_unmanaged() + CourseBundle.objects .filter(Q(courses__groups__id=group) | Q(courses__groups__parent_groups__id=group)) .distinct() .annotate(validity_range_id=Value(validity_range)), diff --git a/aleksis/apps/lesrooster/schema/timebound_course_bundle.py b/aleksis/apps/lesrooster/schema/timebound_course_bundle.py index 891cb1eea229c6b772c290aaba55f2897dabde2c..500be9e8d91124ecc6cca0581fa8d60feeb13191 100644 --- a/aleksis/apps/lesrooster/schema/timebound_course_bundle.py +++ b/aleksis/apps/lesrooster/schema/timebound_course_bundle.py @@ -16,7 +16,7 @@ class TimeboundCourseType(BaseCourseType): def resolve_lesson_quota(root, info): """Resolve lesson_quota from timebound_course_config""" return ( - TimeboundCourseConfig.objects.managed_and_unmanaged() + TimeboundCourseConfig.objects .get( course=root, validity_range__id=root.validity_range_id, @@ -27,7 +27,7 @@ class TimeboundCourseType(BaseCourseType): def resolve_teachers(root, info): """Resolve teachers from timebound_course_config""" return ( - TimeboundCourseConfig.objects.managed_and_unmanaged() + TimeboundCourseConfig.objects .get(course=root, validity_range__id=root.validity_range_id) .teachers.all() )