From 4dae4d0dbfc0d9740e36475b248dab181c8f1aae Mon Sep 17 00:00:00 2001 From: "P. Christeas" Date: Wed, 27 Oct 2010 13:24:28 +0300 Subject: document: base the dir permissions on ir.rule, not on sql call. bzr revid: p_christ@hol.gr-20101027102428-6n2huvvv2o1tiyh6 --- addons/document/document_directory.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'addons/document/document_directory.py') diff --git a/addons/document/document_directory.py b/addons/document/document_directory.py index e75d1861201..82f53b6120b 100644 --- a/addons/document/document_directory.py +++ b/addons/document/document_directory.py @@ -21,6 +21,7 @@ from osv import osv, fields +from osv.orm import except_orm import os import nodes @@ -212,22 +213,20 @@ class document_directory(osv.osv): """ return - def get_dir_permissions(self, cr, uid, ids ): + def get_dir_permissions(self, cr, uid, ids, context=None ): """Check what permission user 'uid' has on directory 'id' """ assert len(ids) == 1 id = ids[0] - cr.execute( "SELECT count(dg.item_id) AS needs, count(ug.uid) AS has " \ - " FROM document_directory_group_rel dg " \ - " LEFT OUTER JOIN res_groups_users_rel ug " \ - " ON (dg.group_id = ug.gid AND ug.uid = %s) " \ - " WHERE dg.item_id = %s ", (uid, id)) - needs, has = cr.fetchone() - if needs and not has: - return 1 # still allow to descend into. - else: - return 15 + res = 0 + for pperms in [('read', 5), ('write', 2), ('unlink', 8)]: + try: + self.check_access_rule(cr, uid, ids, pperms[0], context=context) + res |= pperms[1] + except except_orm: + pass + return res def _locate_child(self, cr, uid, root_id, uri,nparent, ncontext): """ try to locate the node in uri, -- cgit v1.2.3