Skip to content

Conversation

@lecanard539
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