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

make the decorators work with both @classmethod and @staticmethod #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ducky2048
Copy link

This should fix issue #21

@ro70
Copy link

ro70 commented Nov 13, 2018

@Peroxid I tried your fixes and it does not seem to work together with a second decorator.

@classmethod
@authenticated_users
def has_destroy_permission(cls, request):
   ...    

The error thrown is

File "/core/src/dry-rest-permissions/dry_rest_permissions/generics.py", line 262, in to_representation
results[action] = getattr(self.parent.Meta.model, method_names['global'])(self.context['request'])
File "/core/src/dry-rest-permissions/dry_rest_permissions/generics.py", line 306, in func_wrapper
if not(request.user and request.user.is_authenticated):
AttributeError: type object '...' has no attribute 'user'

@ro70
Copy link

ro70 commented Nov 14, 2018

@Peroxid Why not use something like

if args[0].__name__ == 'Request':
            request = args[0]
        else:
            request = args[1]

as proposed by @jjlorenzo in #21

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

Successfully merging this pull request may close these issues.

2 participants