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 +10,10 @@ def has_subject_permissions(user, subject):
10 if user.is_staff: 10 if user.is_staff:
11 return True 11 return True
12 12
13 - if user in subject.professor.all(): 13 + if subject.professor.filter(id = user.id).exists():
14 return True 14 return True
15 15
16 - if user in subject.category.coordinators.all(): 16 + if subject.category.coordinators.filter(id = user.id).exists():
17 return True 17 return True
18 18
19 return False 19 return False
subjects/utils.py
@@ -6,14 +6,14 @@ from django.db.models import Q @@ -6,14 +6,14 @@ from django.db.models import Q
6 6
7 def has_student_profile(user, category): 7 def has_student_profile(user, category):
8 for subject in category.subject_category.all(): 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 return True 10 return True
11 11
12 return False 12 return False
13 13
14 def has_professor_profile(user, category): 14 def has_professor_profile(user, category):
15 for subject in category.subject_category.all(): 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 return True 17 return True
18 18
19 return False 19 return False