Code

Opened 4 years ago

Closed 4 years ago

#12463 closed (wontfix)

user_passes_test should transfer view_func parameters to test_func

Reported by: zigarn Owned by: nobody
Component: Uncategorized Version: 1.1
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

In some case, the test is dependant from view_func parameters.
For example : check user.pk and the user_id parameter to allow users to edit only themselves (and not be able to edit other just by changing the user_id)

Attachments (1)

user_passes_test_decorator.diff (635 bytes) - added by zigarn 4 years ago.
patch for that if accepted

Download all attachments as: .zip

Change History (2)

Changed 4 years ago by zigarn

patch for that if accepted

comment:1 Changed 4 years ago by lukeplant

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to wontfix
  • Status changed from new to closed

Hi, thanks for the suggestion. My feedback:

1) Your patch does not seem to be against trunk.

2) This would break compatibility with all code that provided a test_func which did not accept *args and **kwargs, which is the normal way to write the test_func.

3) The test could also be dependent on other things from the request, as well as *args and **kwargs. But the name of the decorator is 'user_passes_test' i.e. it checks something about the user. As such, the decorator does its job well.

So, if you want a decorator that does this, you can easily write your own, and that doesn't have any compatibility issues.

For these reasons, number 2 especially, I'm closing as WONTFIX.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.