def apply_permissions(self, ns, data, ruleset={}): """ Wrapper function to apply permissions to a data row and return the sanitized result """ if type(ns) != list: ns = ns.split(".") # prepare ruleset if ruleset: _ruleset = {} namespace_str = ".".join(ns) for section, rules in ruleset.items(): _ruleset[section] = {} for rule, perms in rules.items(): _ruleset[section]["%s.%s" % (namespace_str, rule)] = perms ruleset = _ruleset return nsp.dict_get_path( nsp.permissions_apply(nsp.dict_from_namespace(ns, data), self.request.user, ruleset=ruleset), ns)
def apply_permissions(self, ns, data, ruleset={}): """ Wrapper function to apply permissions to a data row and return the sanitized result """ if type(ns) != list: ns = ns.split(".") # prepare ruleset if ruleset: _ruleset = {} namespace_str = ".".join(ns) for section, rules in ruleset.items(): _ruleset[section] = {} for rule, perms in rules.items(): _ruleset[section]["%s.%s" % (namespace_str, rule)] = perms ruleset = _ruleset return nsp.dict_get_path( nsp.permissions_apply( nsp.dict_from_namespace(ns, data), self.request.user, ruleset=ruleset), ns)