Commit 3d0da79a authored by Glaucia S. Santos's avatar Glaucia S. Santos

New filter in messages

parent 485a5611
......@@ -63,11 +63,12 @@ class CourseViewSet(viewsets.ModelViewSet):
).prefetch_related('professors')
# Course must have status status published and (be public or share groups with user)
query = Q(
Q(status='published') & (
Q(is_public=True, ) | Q(groups__in=self.request.user.groups.all(), status='published')
)
)
#query = Q(
# Q(status='published') & (
# Q(is_public=True, ) | Q(groups__in=self.request.user.groups.all(), status='published')
# )
#)
query = Q(status='published')
if (CourseProfessor.objects.filter(user=self.request.user, role='coordinator').exists()):
query.add(Q(
......@@ -171,13 +172,17 @@ class ProfessorMessageViewSet(viewsets.ModelViewSet):
def get_queryset(self):
queryset = super().get_queryset()
query = Q(
Q(users=self.request.user)
| Q(groups__in=self.request.user.groups.all())
| Q(professor=self.request.user)
)
queryset = queryset.filter(query).order_by('-id').distinct()
all_messages = self.request.query_params.get('all_messages', None)
if all_messages:
queryset = queryset.order_by('-id').distinct()
else:
query = Q(
Q(users=self.request.user)
| Q(groups__in=self.request.user.groups.all())
| Q(professor=self.request.user)
)
queryset = queryset.filter(query).order_by('-id').distinct()
classroom = self.request.query_params.get('classroom', None)
if classroom:
......
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