Login

Tag "row-level-permissions"

Snippet List

fancy_if

I am working on some apps that use row level permissions. For many permission tests I intend to make custom tags so I can locate the permission test used by the template and by the view in a common module. However, frequently, before I decide what the actual end-tag is going to be I need a way to expression a more powerful 'if' structure in the template language. Frequently the existing if and if_has_perm tags are just not powerful enough to express these things. This may make the template language unacceptably more like a programming language but it has helped me quickly modify complex permission statements without having to next and repeat four or five clauses. As you can see this is intended to work with django off of the row level permissions branch. Here is an example of a template that is using the 'fancy_if' statement: ` {% fancy_if or ( and not discussion.locked not discussion.closed "asforums.post_discussion" discussion ) "asforums.moderate_forum" discussion.forum %} <li><a href="./create_post/?in_reply_to={{ post.id }}">{% icon "comment_add" "Reply to post" %}</a></li> {% end_fancy_if %} {% fancy_if or "asforums.moderate_forum" discussion.forum ( and not discussion.closed ( or eq post.author user eq discussion.author user ) ) %} {% fancy_if or "asforums.moderate_forum" discussion.forum eq post.author user %} <li><a href="{{ post.get_absolute_url }}update/">{% icon "comment_edit" "Edit Post" %}</a></li> {% end_fancy_if %} <li><a href="{{ post.get_absolute_url }}delete/">{% icon "comment_delete" "Delete Post" %}</a></li> {% end_fancy_if %} `

  • row-level-permissions
  • compound-conditional
Read More

1 snippet posted so far.