From e91d4ff1862857db27fc18d4b0081a94dfef3be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Sat, 2 Dec 2017 01:46:51 +0000 Subject: [PATCH] Add support for acl based on instances --- re2o/templatetags/acl.py | 175 +++++++++++++++++++++++++++------------ 1 file changed, 122 insertions(+), 53 deletions(-) diff --git a/re2o/templatetags/acl.py b/re2o/templatetags/acl.py index d676844a..f92c130d 100644 --- a/re2o/templatetags/acl.py +++ b/re2o/templatetags/acl.py @@ -21,20 +21,27 @@ """ Set of templatetags for using acl in templates: - - can_create - - cannot_create + - can_create (model) + - cannot_create (model) + - can_edit (instance) + - cannot_edit (instance) + +Some templatetags require a model to calculate the acl while others are need +an instance of a model (either Model.can_xxx or instance.can_xxx) **Parameters**: - model_name - The model_name that needs to be checked for the current user + model_name or instance - Either the model_name (if templatetag is based on + model) or an instantiated object (if templatetag is base on instance) + that needs to be checked for the current user args - Any other argument that is interpreted as a python object and passed to the acl function (can_xxx) **Usage**: - {% model [arg1 [arg2 [...]]]%} + {% [arg1 [arg2 [...]]]%}