From ad0713b1a21146db2c503207f42a8fbf7a11373c Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Sat, 18 Jan 2020 19:39:20 +0100
Subject: [PATCH] Add model extension to Person for check if the person is a
 teacher

---
 aleksis/apps/chronos/model_extensions.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/aleksis/apps/chronos/model_extensions.py b/aleksis/apps/chronos/model_extensions.py
index 1d93db9a..62570c63 100644
--- a/aleksis/apps/chronos/model_extensions.py
+++ b/aleksis/apps/chronos/model_extensions.py
@@ -3,6 +3,13 @@ from aleksis.core.models import Person
 from .models import Lesson, LessonPeriod
 
 
+@Person.property
+def is_teacher(self):
+    """ Check if the user has lessons as an teacher """
+
+    return Lesson.objects.filter(teachers=self).exists()
+
+
 @Person.property
 def lessons_as_participant(self):
     """ Return a `QuerySet` containing all `Lesson`s this person
-- 
GitLab