diff --git a/aleksis/apps/chronos/managers.py b/aleksis/apps/chronos/managers.py index 486409f95052b51431fcaf74121690dafcb31d7e..80563bcd4ef1265ca8d03c276a004511eda9df97 100644 --- a/aleksis/apps/chronos/managers.py +++ b/aleksis/apps/chronos/managers.py @@ -799,16 +799,20 @@ class ExtraLessonQuerySet(TimetableQuerySet, SchoolTermRelatedQuerySet, GroupByP class GroupPropertiesMixin: """Mixin for common group properties. - Needed field: `groups` + Necessary method: `get_groups` """ @property def group_names(self, sep: Optional[str] = ", ") -> str: - return sep.join([group.short_name for group in self.groups.all()]) + return sep.join([group.short_name for group in self.get_groups()]) + + @property + def group_short_names(self, sep: Optional[str] = ", ") -> str: + return sep.join([group.short_name for group in self.get_groups()]) @property def groups_to_show(self) -> models.QuerySet: - groups = self.groups.all() + groups = self.get_groups() if ( groups.count() == 1 and groups[0].parent_groups.all() @@ -822,17 +826,36 @@ class GroupPropertiesMixin: def groups_to_show_names(self, sep: Optional[str] = ", ") -> str: return sep.join([group.short_name for group in self.groups_to_show]) + @property + def groups_to_show_short_names(self, sep: Optional[str] = ", ") -> str: + return sep.join([group.short_name for group in self.groups_to_show]) + class TeacherPropertiesMixin: """Mixin for common teacher properties. - Needed field: `teacher` + Necessary method: `get_teachers` """ @property def teacher_names(self, sep: Optional[str] = ", ") -> str: - return sep.join([teacher.full_name for teacher in self.get_teachers().all()]) + return sep.join([teacher.full_name for teacher in self.get_teachers()]) @property def teacher_short_names(self, sep: str = ", ") -> str: - return sep.join([teacher.short_name for teacher in self.get_teachers().all()]) + return sep.join([teacher.short_name for teacher in self.get_teachers()]) + + +class RoomPropertiesMixin: + """Mixin for common room properties. + + Necessary method: `get_rooms` + """ + + @property + def room_names(self, sep: Optional[str] = ", ") -> str: + return sep.join([room.name for room in self.get_rooms()]) + + @property + def room_short_names(self, sep: str = ", ") -> str: + return sep.join([room.short_name for room in self.get_rooms()])