Skip to content
Snippets Groups Projects
Verified Commit b1b46778 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Update common used mixins for groups, teachers, and rooms

parent 0b64ddc3
No related tags found
1 merge request!301New data model based on calendar events
Pipeline #138352 failed
...@@ -799,16 +799,20 @@ class ExtraLessonQuerySet(TimetableQuerySet, SchoolTermRelatedQuerySet, GroupByP ...@@ -799,16 +799,20 @@ class ExtraLessonQuerySet(TimetableQuerySet, SchoolTermRelatedQuerySet, GroupByP
class GroupPropertiesMixin: class GroupPropertiesMixin:
"""Mixin for common group properties. """Mixin for common group properties.
Needed field: `groups` Necessary method: `get_groups`
""" """
@property @property
def group_names(self, sep: Optional[str] = ", ") -> str: 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 @property
def groups_to_show(self) -> models.QuerySet: def groups_to_show(self) -> models.QuerySet:
groups = self.groups.all() groups = self.get_groups()
if ( if (
groups.count() == 1 groups.count() == 1
and groups[0].parent_groups.all() and groups[0].parent_groups.all()
...@@ -822,17 +826,36 @@ class GroupPropertiesMixin: ...@@ -822,17 +826,36 @@ class GroupPropertiesMixin:
def groups_to_show_names(self, sep: Optional[str] = ", ") -> str: def groups_to_show_names(self, sep: Optional[str] = ", ") -> str:
return sep.join([group.short_name for group in self.groups_to_show]) 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: class TeacherPropertiesMixin:
"""Mixin for common teacher properties. """Mixin for common teacher properties.
Needed field: `teacher` Necessary method: `get_teachers`
""" """
@property @property
def teacher_names(self, sep: Optional[str] = ", ") -> str: 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 @property
def teacher_short_names(self, sep: str = ", ") -> str: 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()])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment