Commit 723afc54 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Merge branch 'develop' into 'master'

Enable use of groups

See merge request !64
parents 55abad46 a5056bc9
......@@ -23,7 +23,7 @@ class BasicClassViewSet(viewsets.ReadOnlyModelViewSet):
if not (self.request.user.is_staff or self.request.user.is_superuser):
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)
).distinct()
......@@ -45,4 +45,4 @@ class ClassViewSet(BasicClassViewSet, viewsets.ModelViewSet):
'course__course_students',
)
return queryset
\ No newline at end of file
return queryset
......@@ -335,7 +335,7 @@ class Course(models.Model):
def has_perm_own_all_classes(self, 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):
is_new = self.pk is None
......
......@@ -70,7 +70,7 @@ class CourseViewSet(viewsets.ModelViewSet):
#)
from django.utils.translation import 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()):
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