Opened 15 years ago
Last modified 13 years ago
#13127 new New feature
Template tag "perms" doesn't support object level permission checking
Reported by: | Dana Spiegel | 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)
Change History (9)
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 14 years ago
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 by , 14 years ago
Type: | → New feature |
---|
comment:4 by , 14 years ago
Severity: | → Normal |
---|
comment:7 by , 13 years ago
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 by , 13 years ago
Cc: | added |
---|
by , 13 years ago
Attachment: | permissions.py added |
---|
Missed a debug statement in the previous attachment
{{ 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.