author | Sandrine Ribeau <sandrine.ribeau@logilab.fr> |
Tue, 06 Apr 2010 12:23:10 +0200 | |
changeset 5235 | 3a92e6d92a64 |
parent 5234 | e2476d78b060 |
child 5236 | 13296aa038a9 |
permissions | -rw-r--r-- |
5235
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
1 |
"""Specific views for users and groups |
0 | 2 |
|
3 |
:organization: Logilab |
|
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3808
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1739
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 7 |
""" |
8 |
__docformat__ = "restructuredtext en" |
|
9 |
||
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
10 |
from logilab.mtconverter import xml_escape |
0 | 11 |
|
692
800592b8d39b
replace deprecated cubicweb.common.selectors by its new module path (cubicweb.selectors)
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
688
diff
changeset
|
12 |
from cubicweb.selectors import one_line_rset, implements, match_user_groups |
765
8fda14081686
kill Form, EntityForm and AnyRsetForm
sylvain.thenault@logilab.fr
parents:
753
diff
changeset
|
13 |
from cubicweb.view import EntityView |
2971
bc0a270622c2
B CWUser login is in title, do not show in attributes
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2401
diff
changeset
|
14 |
from cubicweb.web import action, uicfg |
557 | 15 |
|
4719
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
16 |
_pvs = uicfg.primaryview_section |
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
_pvs.tag_attribute(('CWUser', 'login'), 'hidden') |
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
18 |
_pvs.tag_attribute(('CWGroup', 'name'), 'hidden') |
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
19 |
_pvs.tag_subject_of(('CWGroup', 'read_permission', '*'), 'relations') |
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
20 |
_pvs.tag_subject_of(('CWGroup', 'add_permission', '*'), 'relations') |
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
21 |
_pvs.tag_subject_of(('CWGroup', 'delete_permission', '*'), 'relations') |
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
22 |
_pvs.tag_subject_of(('CWGroup', 'update_permission', '*'), 'relations') |
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
23 |
_pvs.tag_object_of(('*', 'in_group', 'CWGroup'), 'relations') |
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
24 |
_pvs.tag_object_of(('*', 'require_group', 'CWGroup'), 'relations') |
3808
60e78e93a0e5
[web ui] primaryview_section tags for CWGroup
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2971
diff
changeset
|
25 |
|
1288
0d0f09c36bba
fix some euser rcategories, drop editgroup form which 1. is unused 2. has no advantage vs muledit of users
sylvain.thenault@logilab.fr
parents:
1153
diff
changeset
|
26 |
class UserPreferencesEntityAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2971
diff
changeset
|
27 |
__regid__ = 'prefs' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1288
diff
changeset
|
28 |
__select__ = (one_line_rset() & implements('CWUser') & |
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
29 |
match_user_groups('owners', 'managers')) |
1508 | 30 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
31 |
title = _('preferences') |
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
32 |
category = 'mainactions' |
1508 | 33 |
|
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
34 |
def url(self): |
3460
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
35 |
login = self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0).login |
e4843535db25
[api] some more _cw / __regid__, automatic tests now pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
36 |
return self._cw.build_url('cwuser/%s'%login, vid='propertiesform') |
631
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
37 |
|
99f5852f8604
major selector refactoring (mostly to avoid looking for select parameters on the target class), start accept / interface unification)
sylvain.thenault@logilab.fr
parents:
619
diff
changeset
|
38 |
|
523 | 39 |
class FoafView(EntityView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2971
diff
changeset
|
40 |
__regid__ = 'foaf' |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1288
diff
changeset
|
41 |
__select__ = implements('CWUser') |
1508 | 42 |
|
523 | 43 |
title = _('foaf') |
44 |
templatable = False |
|
45 |
content_type = 'text/xml' |
|
46 |
||
47 |
def call(self): |
|
950 | 48 |
self.w(u'''<?xml version="1.0" encoding="%s"?> |
619
9efa2cc9c02c
adding foaf_usable views to supports reusing foaf fragment in other views (for instance sioc view)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
586
diff
changeset
|
49 |
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
9efa2cc9c02c
adding foaf_usable views to supports reusing foaf fragment in other views (for instance sioc view)
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
586
diff
changeset
|
50 |
xmlns:rdfs="http://www.w3org/2000/01/rdf-schema#" |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
51 |
xmlns:foaf="http://xmlns.com/foaf/0.1/"> '''% self._cw.encoding) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
52 |
for i in xrange(self.cw_rset.rowcount): |
523 | 53 |
self.cell_call(i, 0) |
54 |
self.w(u'</rdf:RDF>\n') |
|
55 |
||
56 |
def cell_call(self, row, col): |
|
3457
0924d0d08d60
[api] __regid__, cw_* and friends
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
57 |
entity = self.cw_rset.complete_entity(row, col) |
555
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
58 |
self.w(u'''<foaf:PersonalProfileDocument rdf:about=""> |
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
59 |
<foaf:maker rdf:resource="%s"/> |
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
60 |
<foaf:primaryTopic rdf:resource="%s"/> |
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
61 |
</foaf:PersonalProfileDocument>''' % (entity.absolute_url(), entity.absolute_url())) |
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
62 |
self.w(u'<foaf:Person rdf:ID="%s">\n' % entity.eid) |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
63 |
self.w(u'<foaf:name>%s</foaf:name>\n' % xml_escape(entity.dc_long_title())) |
523 | 64 |
if entity.surname: |
555
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
65 |
self.w(u'<foaf:family_name>%s</foaf:family_name>\n' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
66 |
% xml_escape(entity.surname)) |
523 | 67 |
if entity.firstname: |
555
b40d885ba7a4
new foaf version
Laure Bourgois <Laure.Bourgois@logilab.fr>
parents:
523
diff
changeset
|
68 |
self.w(u'<foaf:givenname>%s</foaf:givenname>\n' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
69 |
% xml_escape(entity.firstname)) |
523 | 70 |
emailaddr = entity.get_email() |
71 |
if emailaddr: |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
72 |
self.w(u'<foaf:mbox>%s</foaf:mbox>\n' % xml_escape(emailaddr)) |
586 | 73 |
self.w(u'</foaf:Person>\n') |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
74 |
|
5235
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
75 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
76 |
# group views ################################################################## |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
77 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
78 |
_pvs.tag_object_of(('CWUser', 'in_group', 'CWGroup'), 'hidden') |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
79 |
_pvs.tag_object_of(('*', 'require_group', 'CWGroup'), 'hidden') |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
80 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
81 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
82 |
class CWGroupPrimaryView(tabs.TabbedPrimaryView): |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
83 |
__select__ = implements('CWGroup') |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
84 |
tabs = [_('cwgroup-main'), _('cwgroup-permissions')] |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
85 |
default_tab = 'cwgroup-main' |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
86 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
87 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
88 |
class CWGroupMainTab(tabs.PrimaryTab): |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
89 |
__regid__ = 'cwgroup-main' |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
90 |
__select__ = tabs.PrimaryTab.__select__ & implements('CWGroup') |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
91 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
92 |
def render_entity_attributes(self, entity, siderelations=None): |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
93 |
rql = 'Any U, FN, LN, CD, LL ORDERBY L WHERE U in_group G, ' \ |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
94 |
'U login L, U firstname FN, U surname LN, U creation_date CD, ' \ |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
95 |
'U last_login_time LL, G eid %(x)s' |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
96 |
rset = self._cw.execute(rql, {'x': entity.eid}) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
97 |
headers = (_(u'user'), _(u'first name'), _(u'last name'), |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
98 |
_(u'creation date'), _(u'last login time')) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
99 |
self.wview('editable-table', rset, 'null', displayfilter=True, |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
100 |
displaycols=range(5), mainindex=0, headers=headers) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
101 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
102 |
class CWGroupPermTab(EntityView): |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
103 |
__regid__ = 'cwgroup-permissions' |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
104 |
__select__ = implements('CWGroup') |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
105 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
106 |
def cell_call(self, row, col): |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
107 |
self._cw.add_css(('cubicweb.schema.css','cubicweb.acl.css')) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
108 |
access_types = ('read', 'delete', 'add', 'update') |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
109 |
w = self.w |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
110 |
entity = self.cw_rset.get_entity(row, col) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
111 |
objtype_access = {'CWEType': ('read', 'delete', 'add', 'update'), |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
112 |
'CWRelation': ('add', 'delete')} |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
113 |
rql_cwetype = 'DISTINCT Any X WHERE X %s_permission CWG, X is CWEType, ' \ |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
114 |
'CWG eid %%(e)s' |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
115 |
rql_cwrelation = 'DISTINCT Any RT WHERE X %s_permission CWG, X is CWRelation, ' \ |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
116 |
'X relation_type RT, CWG eid %%(e)s' |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
117 |
self.render_objtype_access(entity, 'CWEType', objtype_access, rql_cwetype) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
118 |
self.render_objtype_access(entity, 'CWRelation', objtype_access, rql_cwrelation) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
119 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
120 |
def render_objtype_access(self, entity, objtype, objtype_access, rql): |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
121 |
self.w(u'<h4>%s</h4>' % self._cw._(objtype)) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
122 |
for access_type in objtype_access[objtype]: |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
123 |
rset = self._cw.execute(rql % access_type, {'e': entity.eid}) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
124 |
if rset: |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
125 |
self.w(u'<div>Can %s:</div>' % access_type) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
126 |
self.w(u'<div>%s</div><br/>' % self.view('csv', rset, 'null')) |
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
127 |
|
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
128 |
class CWGroupInContextView(EntityView): |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
129 |
__regid__ = 'incontext' |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
130 |
__select__ = implements('CWGroup') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
131 |
|
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
132 |
def cell_call(self, row, col): |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
133 |
entity = self.cw_rset.complete_entity(row, col) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
134 |
self.w(u'<a href="%s" class="%s">%s</a>' % ( |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
135 |
entity.absolute_url(), entity.name, entity.printable_value('name'))) |