Opened 7 years ago

Last modified 7 years ago

#29220 closed New feature

Auth: change user_passes_test func, new arg arg_position add — at Initial Version

Reported by: Oscar Lopez Owned by: nobody
Component: contrib.auth Version: 1.11
Severity: Normal Keywords: Auth, user_passes_test, decorator
Cc: oscarjoselopez26@…, Oscar Lopez Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

I had problems Add my decorations user_passes_test functions, because decorator _wrapped_view assume, the first arg is the requests parameter, when i call user_passes_test from a view into a class, that not work, it take the arg self look like a arg request

example:
def index(self, request):

Fatal error: Class don't have attribute user.

This Change work for Django 1.11
but i see that file dont change a lot in Django 2.X

Now i can call the auth:

@user_passes_test(role_client_check, arg_position=0)

def index(self, request):

arg_position can be specific when the first argument isn't "request"
arg_position is a integer with the position of request on view function

I created my own user_passes_test function to solve this feature.

Change History (1)

by Oscar Lopez, 7 years ago

Attachment: decorators.py added

\django\contrib\auth\decorators.py just one file update

Note: See TracTickets for help on using tickets.
Back to Top