#29220: Auth: change user_passes_test func, new arg arg_position add
-------------------------------------+-------------------------------------
     Reporter:  Oscar Lopez          |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  contrib.auth         |                  Version:  1.11
     Severity:  Normal               |               Resolution:
     Keywords:  Auth,                |             Triage Stage:
  user_passes_test, decorator        |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Oscar Lopez):

 * type:  Uncategorized => New feature


Old 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.

New description:

 I had problems Add my decorations user_passes_test functions, because
 decorator _wrapped_view assume, the first arg is the `request` var
 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:
 `@user_passes_test(role_client_check)`
    `def index(self, request):`

 Fatal error: Class don't have attribute user.

 The next new change work for Django 1.11
 but i see that Django 2.X file, doesn't change a lot

 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.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29220#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/073.8da025bbff8d69dae086ea76be998898%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to