Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClassViewSet retorna todos os resultados se usuário não tiver nenhum role configurado #620

Open
laurybueno opened this issue Nov 24, 2016 · 0 comments
Assignees
Labels

Comments

@laurybueno
Copy link
Member

laurybueno commented Nov 24, 2016

Problema aparece no get_queryset da classe

timtec/core/views.py

    def get_queryset(self):
        queryset = super(ClassViewSet, self).get_queryset()
        if self.request.user.is_staff or self.request.user.is_superuser:
            return queryset

        course_id = self.request.query_params.get('course')
        if course_id:
            try:
                role = self.request.user.teaching_courses.get(course__id=course_id).role
            except ObjectDoesNotExist:
                role = ''
            # if user is not coordinator or admin, only show his classes
            if not role or role == 'assistant':
                queryset = queryset.filter(assistant=self.request.user)

        return queryset
@laurybueno laurybueno added the bug label Nov 24, 2016
@laurybueno laurybueno self-assigned this Nov 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant