Code

Opened 4 years ago

Last modified 2 years ago

#13127 new New feature

Template tag "perms" doesn't support object level permission checking

Reported by: danaspiegel Owned by: nobody
Component: contrib.auth Version: 1.2-beta
Severity: Normal Keywords:
Cc: tarkatronic@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

This should be a quick fix, but the perms template tag doesn't allow the specification of an object in order to test for object level permissions.

Attachments (1)

permissions.py (2.1 KB) - added by Tarken 2 years ago.
Missed a debug statement in the previous attachment

Download all attachments as: .zip

Change History (9)

comment:1 Changed 4 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

{{ perms }} isn't a template tag -- it's an object put into the context by the PermWrapper context processor. However, the use case is valid.

comment:2 Changed 3 years ago by aidan

Is there a workaround for this? From looking at the core context processor's PermWrapper it doesn't look like an easy change.

comment:3 Changed 3 years ago by lukeplant

  • Type set to New feature

comment:4 Changed 3 years ago by lukeplant

  • Severity set to Normal

comment:5 Changed 2 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:6 Changed 2 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:7 Changed 2 years ago by Tarken

I had need to tackle this for a project I am working on; this was one of the final pieces in fully implementing generic row-level permissions, so I figured I would share my results. I couldn't figure out a way to make this work cleanly and easily with the PermWrapper context processor, so I ended up creating a new template tag, {% ifpermitted %}. I will attach the code momentarily. If there is any interest in using this approach, I could work up docs/tests for this tag (or gladly let somebody else do those, as I have zero experience with them)

comment:8 Changed 2 years ago by Tarken

  • Cc tarkatronic@… added

Changed 2 years ago by Tarken

Missed a debug statement in the previous attachment

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as new
The owner will be changed from nobody to anonymous. Next status will be 'assigned'
as The resolution will be set. Next status will be 'closed'
Author


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

 
Note: See TracTickets for help on using tickets.