27 class CWGroup(AnyEntity): |
27 class CWGroup(AnyEntity): |
28 __regid__ = 'CWGroup' |
28 __regid__ = 'CWGroup' |
29 fetch_attrs, fetch_order = fetch_config(['name']) |
29 fetch_attrs, fetch_order = fetch_config(['name']) |
30 fetch_unrelated_order = fetch_order |
30 fetch_unrelated_order = fetch_order |
31 |
31 |
32 def db_key_name(self): |
32 def grant_permission(self, entity, pname, plabel=None): |
33 """XXX goa specific""" |
33 """grant local `pname` permission on `entity` to this group using |
34 return self.get('name') |
34 :class:`CWPermission`. |
|
35 |
|
36 If a similar permission already exists, add the group to it, else create |
|
37 a new one. |
|
38 """ |
|
39 if not self._cw.execute( |
|
40 'SET X require_group G WHERE E eid %(e)s, G eid %(g)s, ' |
|
41 'E require_permission X, X name %(name)s, X label %(label)s', |
|
42 {'e': entity.eid, 'g': self.eid, |
|
43 'name': pname, 'label': plabel}): |
|
44 self._cw.create_entity('CWPermission', name=pname, label=plabel, |
|
45 require_group=self, |
|
46 reverse_require_permission=entity) |
35 |
47 |
36 |
48 |
37 class CWUser(AnyEntity): |
49 class CWUser(AnyEntity): |
38 __regid__ = 'CWUser' |
50 __regid__ = 'CWUser' |
39 fetch_attrs, fetch_order = fetch_config(['login', 'firstname', 'surname']) |
51 fetch_attrs, fetch_order = fetch_config(['login', 'firstname', 'surname']) |
154 def dc_title(self): |
166 def dc_title(self): |
155 return self.login |
167 return self.login |
156 |
168 |
157 dc_long_title = name |
169 dc_long_title = name |
158 |
170 |
159 def db_key_name(self): |
|
160 """XXX goa specific""" |
|
161 return self.get('login') |
|
162 |
|
163 from logilab.common.deprecation import class_renamed |
171 from logilab.common.deprecation import class_renamed |
164 EUser = class_renamed('EUser', CWUser) |
172 EUser = class_renamed('EUser', CWUser) |
165 EGroup = class_renamed('EGroup', CWGroup) |
173 EGroup = class_renamed('EGroup', CWGroup) |