[Django] #24294: admin.views.decorators.staff_member_required raises an exception when passed a valid argument

22 views
Skip to first unread message

Django

unread,
Feb 6, 2015, 1:32:39 PM2/6/15
to django-...@googlegroups.com
#24294: admin.views.decorators.staff_member_required raises an exception when
passed a valid argument
-------------------------------+----------------------
Reporter: akulakov | Owner: akulakov
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------+----------------------
When a valid argument is given to staff_member_required decorator, it
raises this confusing error:

staff_member_required() takes at least 1 argument (1 given)

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

Django

unread,
Feb 6, 2015, 1:33:26 PM2/6/15
to django-...@googlegroups.com
#24294: admin.views.decorators.staff_member_required raises an exception when
passed a valid argument
-------------------------------+--------------------------------------

Reporter: akulakov | Owner: akulakov
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Changes (by akulakov):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Old description:

> When a valid argument is given to staff_member_required decorator, it
> raises this confusing error:
>
> staff_member_required() takes at least 1 argument (1 given)

New description:

When a valid argument is given to staff_member_required decorator, it
raises this confusing error:

staff_member_required() takes at least 1 argument (1 given)

e.g.:
@staff_member_required(redirect_field_name='test')
def v1(request):
return HttpResponse("hi")

--

--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:1>

Django

unread,
Feb 6, 2015, 1:34:51 PM2/6/15
to django-...@googlegroups.com
#24294: admin.views.decorators.staff_member_required raises an exception when
passed a valid argument
-------------------------------+--------------------------------------

Reporter: akulakov | Owner: akulakov
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by akulakov:

Old description:

> When a valid argument is given to staff_member_required decorator, it
> raises this confusing error:
>
> staff_member_required() takes at least 1 argument (1 given)
>

> e.g.:
> @staff_member_required(redirect_field_name='test')
> def v1(request):
> return HttpResponse("hi")

New description:

When a valid argument is given to staff_member_required decorator, it
raises this confusing error:

staff_member_required() takes at least 1 argument (1 given)

e.g.::


@staff_member_required(redirect_field_name='test')
def v1(request):
return HttpResponse("hi")

--

--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:2>

Django

unread,
Feb 6, 2015, 1:36:34 PM2/6/15
to django-...@googlegroups.com
#24294: admin.views.decorators.staff_member_required raises an exception when
passed a valid argument
-------------------------------+--------------------------------------

Reporter: akulakov | Owner: akulakov
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+--------------------------------------
Description changed by akulakov:

Old description:

> When a valid argument is given to staff_member_required decorator, it


> raises this confusing error:
>
> staff_member_required() takes at least 1 argument (1 given)
>

> e.g.::
> @staff_member_required(redirect_field_name='test')
> def v1(request):
> return HttpResponse("hi")

New description:

When a valid argument is given to staff_member_required decorator, it
raises this confusing error:

staff_member_required() takes at least 1 argument (1 given)

{{{


@staff_member_required(redirect_field_name='test')
def v1(request):
return HttpResponse("hi")
}}}

--

--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:3>

Django

unread,
Feb 6, 2015, 2:33:06 PM2/6/15
to django-...@googlegroups.com
#24294: admin.views.decorators.staff_member_required can't be used with decorator
syntax and extra arguments
-------------------------------+------------------------------------

Reporter: akulakov | Owner: akulakov
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by carljm):

* stage: Unreviewed => Accepted


Comment:

The issue here is simply that `staff_member_required` is not written to be
automatically either a decorator or decorator-factory: it always requires
a `view_func` as its first positional argument. So it simply doesn't
support the way you are trying to use it; if you want to provide extra
options to it, you can no longer use it with `@` syntax.

If we are documenting it and making it public API, it should probably work
like `login_required`, which would make your code work.

--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:4>

Django

unread,
Feb 6, 2015, 2:47:24 PM2/6/15
to django-...@googlegroups.com
#24294: admin.views.decorators.staff_member_required can't be used with decorator
syntax and extra arguments
-------------------------------+------------------------------------
Reporter: akulakov | Owner: akulakov
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by collinanderson):

#24253 is about making staff_member_required a public api.

--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:5>

Django

unread,
Mar 1, 2015, 6:07:14 PM3/1/15
to django-...@googlegroups.com
#24294: admin.views.decorators.staff_member_required can't be used with decorator
syntax and extra arguments
-------------------------------+------------------------------------
Reporter: akulakov | Owner: akulakov
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------

Comment (by johngian):

I pushed a branch with a fix for that ticket here:
https://github.com/johngian/django/tree/ticket_24294

--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:6>

Django

unread,
Mar 1, 2015, 11:53:22 PM3/1/15
to django-...@googlegroups.com
#24294: admin.views.decorators.staff_member_required can't be used with decorator
syntax and extra arguments
-------------------------------+------------------------------------
Reporter: akulakov | Owner: akulakov
Type: Bug | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by charettes):

* has_patch: 0 => 1
* needs_tests: 0 => 1


Comment:

Can you point to the existing pull request?

This will also require a test.

--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:7>

Django

unread,
Mar 2, 2015, 1:26:43 PM3/2/15
to django-...@googlegroups.com
#24294: admin.views.decorators.staff_member_required can't be used with decorator
syntax and extra arguments
-------------------------------+------------------------------------
Reporter: akulakov | Owner: akulakov
Type: Bug | Status: closed
Component: contrib.admin | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: new => closed
* resolution: => fixed


Comment:

In [changeset:"08572e8d125da204fab230be5d1fdcc5d8d22256"]:
{{{
#!CommitTicketReference repository=""
revision="08572e8d125da204fab230be5d1fdcc5d8d22256"
Fixed #24294 -- Allowed staff_member_required decorator to handle args.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24294#comment:8>

Reply all
Reply to author
Forward
0 new messages