Skip to content

Commit

Permalink
Shorten query to get subscribed_tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
TuringTux committed Nov 25, 2019
1 parent 3f37054 commit 67cf08c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions muesli/web/viewsLecture.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,7 @@ def __init__(self, request):
def __call__(self):
lecture = self.db.query(models.Lecture).options(undefer('tutorials.student_count')).get(self.lecture_id)
times = lecture.prepareTimePreferences(user=self.request.user)
subscribed_tutorial = self.db.query(models.Tutorial).filter(
Tutorial.lecture_students.any(
LectureStudent.student_id == self.request.user.id and LectureStudent.lecture_id == self.lecture_id
)
).first()
subscribed_tutorial = self.request.user.tutorials.filter(LectureStudent.lecture_id == self.lecture_id).first()
return {'lecture': lecture,
'subscribed_tutorial': subscribed_tutorial,
'times': times,
Expand Down

0 comments on commit 67cf08c

Please sign in to comment.