From b83c6f864693d7a2117b71be9bb341673f66879e Mon Sep 17 00:00:00 2001
From: Dominik George <dominik.george@teckids.org>
Date: Sat, 31 Aug 2019 21:48:45 +0200
Subject: [PATCH] Fix listing of teachers and groups in lesson view. Advances
 #11, #12.

---
 biscuit/apps/chronos/models.py | 8 ++++++++
 biscuit/apps/chronos/tables.py | 4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/biscuit/apps/chronos/models.py b/biscuit/apps/chronos/models.py
index fc9127f3..ed0ebf59 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 90075c03..2be4f609 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')
-- 
GitLab