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

Issue with *list_route* decorator #3599

Closed
Heroico opened this issue Nov 4, 2015 · 4 comments
Closed

Issue with *list_route* decorator #3599

Heroico opened this issue Nov 4, 2015 · 4 comments

Comments

@Heroico
Copy link

Heroico commented Nov 4, 2015

Hi there!

I have added an HTTP method to a view set, with the SimpleRouter and the list_route decorator.
I am having an issue with the permission classes for this method alone. I set a permission (different from the ViewSet) in the decorator as in the current docs:

#/jobs/
class JobViewSet(ModelViewSet):
    serializer_class = JobSerializer
    permission_classes = (AuthenticatedOwnerPermission, )
...
    #/jobs/active
    @list_route(methods=['get'], permission_classes=[AuthenticatedUserPermission])
    def active(self, request, *args, **kwargs):
        active = Job.active_job(self.request.user)
        data = self.get_serializer(active).data if active else None
        return Response(data)

But this different permission class is ignored. Maybe this is on purpose?
Or should it be working as it is, and the problem is elsewhere?

Thanks!

@tomchristie
Copy link
Member

Looks fine on first sight. Assume problem is elsewhere?... (Sorry brief, on phone)

@Heroico
Copy link
Author

Heroico commented Nov 5, 2015

Well, it beats me. My user case is pretty simple actually. I added some logging, and neither the ViewSet permission class nor the decorator one are being called.

Please let me know if there if there is any information I could provide to sort this out, or any suggestion. Thanks again!

@dursk
Copy link
Contributor

dursk commented Dec 5, 2015

Just set this up from scratch and ran through it all locally: using the @list_route decorator on a ViewSet and specifying a permission_classes that is different than the one of the class. Everything checked out and seems to be working as expected, the permission class specified in the decorator is the one being called when hitting the endpoint for that view.

So with that being said, I'm going to say that the problem is elsewhere.

@tomchristie
Copy link
Member

Closing pending a reproducible example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants