Commit 3afceffba80bc3e49bf0edc77110116d9192127b

Authored by Zambom
1 parent db1e425a

Some optimizations

Showing 2 changed files with 4 additions and 4 deletions   Show diff stats
amadeus/permissions.py
... ... @@ -10,10 +10,10 @@ def has_subject_permissions(user, subject):
10 10 if user.is_staff:
11 11 return True
12 12  
13   - if user in subject.professor.all():
  13 + if subject.professor.filter(id = user.id).exists():
14 14 return True
15 15  
16   - if user in subject.category.coordinators.all():
  16 + if subject.category.coordinators.filter(id = user.id).exists():
17 17 return True
18 18  
19 19 return False
... ...
subjects/utils.py
... ... @@ -6,14 +6,14 @@ from django.db.models import Q
6 6  
7 7 def has_student_profile(user, category):
8 8 for subject in category.subject_category.all():
9   - if user in subject.students.all() and subject.visible:
  9 + if subject.students.filter(id = user.id).exists() and subject.visible:
10 10 return True
11 11  
12 12 return False
13 13  
14 14 def has_professor_profile(user, category):
15 15 for subject in category.subject_category.all():
16   - if user in subject.professor.all() and subject.visible:
  16 + if subject.professor.filter(id = user.id).exists() and subject.visible:
17 17 return True
18 18  
19 19 return False
... ...