From 7aa8c50360a720a25ac9be399fe204264665cc17 Mon Sep 17 00:00:00 2001 From: AndrzejMorawski00 Date: Wed, 27 Nov 2024 21:54:23 +0100 Subject: [PATCH] change queryset to prevent duplicates --- zapisy/apps/theses/models.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zapisy/apps/theses/models.py b/zapisy/apps/theses/models.py index bc421bfa19..a045114667 100644 --- a/zapisy/apps/theses/models.py +++ b/zapisy/apps/theses/models.py @@ -45,11 +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) return self.filter( (~Q(status=ThesisStatus.BEING_EVALUATED) & ~Q(status=ThesisStatus.RETURNED_FOR_CORRECTIONS)) | Q(advisor__user=user) | Q(supporting_advisor__user=user) | - Q(students__user=user)).distinct() + Q(id__in=student_theses)) class Thesis(models.Model):