From 3afceffba80bc3e49bf0edc77110116d9192127b Mon Sep 17 00:00:00 2001 From: Zambom Date: Tue, 17 Jan 2017 20:40:34 -0200 Subject: [PATCH] Some optimizations --- amadeus/permissions.py | 4 ++-- subjects/utils.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/amadeus/permissions.py b/amadeus/permissions.py index 78bb281..c7486de 100644 --- a/amadeus/permissions.py +++ b/amadeus/permissions.py @@ -10,10 +10,10 @@ def has_subject_permissions(user, subject): if user.is_staff: return True - if user in subject.professor.all(): + if subject.professor.filter(id = user.id).exists(): return True - if user in subject.category.coordinators.all(): + if subject.category.coordinators.filter(id = user.id).exists(): return True return False diff --git a/subjects/utils.py b/subjects/utils.py index 078fd01..a1d99f5 100644 --- a/subjects/utils.py +++ b/subjects/utils.py @@ -6,14 +6,14 @@ from django.db.models import Q def has_student_profile(user, category): for subject in category.subject_category.all(): - if user in subject.students.all() and subject.visible: + if subject.students.filter(id = user.id).exists() and subject.visible: return True return False def has_professor_profile(user, category): for subject in category.subject_category.all(): - if user in subject.professor.all() and subject.visible: + if subject.professor.filter(id = user.id).exists() and subject.visible: return True return False -- libgit2 0.21.2