diff options
| author | P. Christeas <p_christ@hol.gr> | 2010-10-27 13:24:28 +0300 |
|---|---|---|
| committer | P. Christeas <p_christ@hol.gr> | 2010-10-27 13:24:28 +0300 |
| commit | 4dae4d0dbfc0d9740e36475b248dab181c8f1aae (patch) | |
| tree | cf9d6daa001af14ad970467c122a2a4ebbb5de2c /addons/document/document_directory.py | |
| parent | d0b6bf11812fd80812aef2ad79e297a7dc8d537a (diff) | |
document: base the dir permissions on ir.rule, not on sql call.
bzr revid: p_christ@hol.gr-20101027102428-6n2huvvv2o1tiyh6
Diffstat (limited to 'addons/document/document_directory.py')
| -rw-r--r-- | addons/document/document_directory.py | 21 |
1 files changed, 10 insertions, 11 deletions
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, |
