#29220: Auth: change user_passes_test func, new arg arg_position add
-------------------------------------+-------------------------------------
Reporter: Oscar | Owner: nobody
Lopez |
Type: | Status: new
Uncategorized |
Component: | Version: 1.11
contrib.auth | Keywords: Auth,
Severity: Normal | user_passes_test, decorator
Triage Stage: | Has patch: 1
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 1
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/29220>
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/058.903c81f9a5acf7e70169d8d044f888b4%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.