diff --git a/biscuit/apps/chronos/models.py b/biscuit/apps/chronos/models.py index fc9127f326ab5c953db68e797897e8b66e2128ef..ed0ebf592b1d63b01f17ce836ce2b174ab54d293 100644 --- a/biscuit/apps/chronos/models.py +++ b/biscuit/apps/chronos/models.py @@ -89,6 +89,14 @@ class Lesson(models.Model): date_end = models.DateField(verbose_name=_( 'Effective end date of lesson'), null=True) + @property + def teacher_names(self, sep: Optional[str] = ', ') -> str: + return sep.join([teacher.name for teacher in self.teachers.all()]) + + @property + def group_names(self, sep: Optional[str] = ', ') -> str: + return sep.join([group.name for group in self.groups.all()]) + class Meta: ordering = ['date_start'] diff --git a/biscuit/apps/chronos/tables.py b/biscuit/apps/chronos/tables.py index 90075c03db5d0277129057202e3563d277e6f984..2be4f6093f6fd4c3397d3762907fb0a5893bead6 100644 --- a/biscuit/apps/chronos/tables.py +++ b/biscuit/apps/chronos/tables.py @@ -7,7 +7,7 @@ class LessonsTable(tables.Table): attrs = {'class': 'table table-striped table-bordered table-hover table-responsive-xl'} period__period = tables.Column(accessor='period.period') - lesson__groups = tables.Column(accessor='lesson.groups') - lesson__teachers = tables.Column(accessor='lesson.teachers') + lesson__groups = tables.Column(accessor='lesson.group_names') + lesson__teachers = tables.Column(accessor='lesson.teacher_names') lesson__subject = tables.Column(accessor='lesson.subject') room = tables.Column(accessor='room')