From 8bdb9852354c72ada89be42cab25ab82233f48b3 Mon Sep 17 00:00:00 2001 From: AndrzejMorawski00 Date: Tue, 3 Dec 2024 18:05:28 +0100 Subject: [PATCH] move filter logic into user_theses object --- zapisy/apps/theses/models.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/zapisy/apps/theses/models.py b/zapisy/apps/theses/models.py index a045114667..75bee2fd92 100644 --- a/zapisy/apps/theses/models.py +++ b/zapisy/apps/theses/models.py @@ -45,12 +45,12 @@ class ThesesQuerySet(models.QuerySet): def visible(self, user): if user.is_staff or is_theses_board_member(user): return self - student_theses = self.filter(students__user=user) + + user_theses = self.filter(Q(students__user=user) | Q(advisor__user=user) | Q(supporting_advisor__user=user)) return self.filter( - (~Q(status=ThesisStatus.BEING_EVALUATED) & ~Q(status=ThesisStatus.RETURNED_FOR_CORRECTIONS)) | - Q(advisor__user=user) | - Q(supporting_advisor__user=user) | - Q(id__in=student_theses)) + (~Q(status=ThesisStatus.BEING_EVALUATED) & + ~Q(status=ThesisStatus.RETURNED_FOR_CORRECTIONS)) | + Q(id__in=user_theses)) class Thesis(models.Model):