Commit a5056bc9 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Enable use of groups

parent 13974a60
...@@ -23,7 +23,7 @@ class BasicClassViewSet(viewsets.ReadOnlyModelViewSet): ...@@ -23,7 +23,7 @@ class BasicClassViewSet(viewsets.ReadOnlyModelViewSet):
if not (self.request.user.is_staff or self.request.user.is_superuser): if not (self.request.user.is_staff or self.request.user.is_superuser):
queryset = queryset.filter( queryset = queryset.filter(
Q(course__professors=self.request.user, course__course_professors__role='coordinator') | Q(course__professors=self.request.user, course__course_professors__role__in=['coordinator', 'assistant']) |
Q(assistants=self.request.user) Q(assistants=self.request.user)
).distinct() ).distinct()
......
...@@ -335,7 +335,7 @@ class Course(models.Model): ...@@ -335,7 +335,7 @@ class Course(models.Model):
def has_perm_own_all_classes(self, user): def has_perm_own_all_classes(self, user):
role = self.get_professor_role(user) role = self.get_professor_role(user)
return role == 'coordinator' or user.is_superuser return role == 'coordinator' or role == 'assistant' or user.is_superuser
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
is_new = self.pk is None is_new = self.pk is None
......
...@@ -70,7 +70,7 @@ class CourseViewSet(viewsets.ModelViewSet): ...@@ -70,7 +70,7 @@ class CourseViewSet(viewsets.ModelViewSet):
#) #)
from django.utils.translation import get_language from django.utils.translation import get_language
current_language = get_language() current_language = get_language()
query = Q(status='published', lang__contains=[current_language]) query = Q(Q(status='published', lang__contains=[current_language]) | Q(groups__in=self.request.user.groups.all()))
if (CourseProfessor.objects.filter(user=self.request.user, role='coordinator').exists()): if (CourseProfessor.objects.filter(user=self.request.user, role='coordinator').exists()):
query.add(Q( query.add(Q(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment