Skip to content

Commit

Permalink
move filter logic into user_theses object
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrzejMorawski00 committed Dec 3, 2024
1 parent 7aa8c50 commit e162e47
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions zapisy/apps/theses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,10 @@ 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(id__in=student_theses))

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(id__in=user_theses))

class Thesis(models.Model):
"""Represents a thesis in the theses system.
Expand Down

0 comments on commit e162e47

Please sign in to comment.