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

Permission_class is ignored #30

Closed
martinwk opened this issue Sep 12, 2017 · 2 comments
Closed

Permission_class is ignored #30

martinwk opened this issue Sep 12, 2017 · 2 comments

Comments

@martinwk
Copy link

martinwk commented Sep 12, 2017

As PandasView inherits from APIListView I would expect that the attribute permission_classes can be used
to set permission on this view. However, the following view can be accessed when logged out

class DownloadFileViewAPI(PandasView):
    queryset = Well.objects.all()
    permission_classes = (MayUploadWriteOrDownloadRead,)
    filter_class = WellFilter
   
    serializer_class        = MetaDataSerializer # extends Serializer
    pandas_serializer_class = FlatteningPandasSerializer
    renderer_classes        = [PandasExcelNoColNoIndexRenderer,
                               PandasCSVNoColNoIndexRenderer,
                               PandasJSONRenderer]

While the following view can only be accessed when logged in

class WellList(generics.ListAPIView):
    queryset = Well.objects.all()
    permission_classes = (MayUploadWriteOrDownloadRead,)
    serializer_class = WellSerializer
    filter_class = WellFilter

The only difference is the serializer class and the View they inherit from so I would say this is something with PandasView, but I cannot guess why. Am I missing something here?

Adding these mixin's restricts the view to logged in users again.

class DownloadFileViewAPI(LoginRequiredMixin, PandasView):

So this is my workaround for now

@sheppard
Copy link
Member

I wasn't able to reproduce this issue - can you check that your view has permission_classes and not permission_class? PandasView directly inherits from ListAPIView so it should mostly use the same logic.

@sheppard
Copy link
Member

Closing this for now - let me know if it's still an issue.

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

No branches or pull requests

2 participants