author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Fri, 14 Jan 2011 08:10:41 +0100 | |
changeset 6824 | 026581ea2b16 |
parent 6582 | 8eb7883b4223 |
child 6891 | e409a012c505 |
permissions | -rw-r--r-- |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
1 |
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5423
e15abfdcce38
backport default into stable: stable is now cw 3.8
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
18 |
"""Specific views for users and groups""" |
0 | 19 |
|
20 |
__docformat__ = "restructuredtext en" |
|
6582
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6339
diff
changeset
|
21 |
_ = unicode |
0 | 22 |
|
6325
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
23 |
import hashlib |
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
24 |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
25 |
from logilab.mtconverter import xml_escape |
0 | 26 |
|
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
27 |
from cubicweb.selectors import one_line_rset, is_instance, match_user_groups |
765
8fda14081686
kill Form, EntityForm and AnyRsetForm
sylvain.thenault@logilab.fr
parents:
753
diff
changeset
|
28 |
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
|
29 |
from cubicweb.web import action, uicfg |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
30 |
from cubicweb.web.views import tabs |
557 | 31 |
|
4719
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
32 |
_pvs = uicfg.primaryview_section |
aaed3f813ef8
kill dead/useless code as suggested by pylint
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
33 |
_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
|
34 |
_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
|
35 |
_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
|
36 |
_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
|
37 |
_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
|
38 |
_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
|
39 |
_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
|
40 |
_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
|
41 |
|
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
|
42 |
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
|
43 |
__regid__ = 'prefs' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
44 |
__select__ = (one_line_rset() & is_instance('CWUser') & |
728
a95b284150d1
first pass to use __select__ instead of __selectors__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
692
diff
changeset
|
45 |
match_user_groups('owners', 'managers')) |
1508 | 46 |
|
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
|
47 |
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
|
48 |
category = 'mainactions' |
1508 | 49 |
|
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
|
50 |
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
|
51 |
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
|
52 |
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
|
53 |
|
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
|
54 |
|
523 | 55 |
class FoafView(EntityView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2971
diff
changeset
|
56 |
__regid__ = 'foaf' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
57 |
__select__ = is_instance('CWUser') |
1508 | 58 |
|
523 | 59 |
title = _('foaf') |
60 |
templatable = False |
|
61 |
content_type = 'text/xml' |
|
62 |
||
63 |
def call(self): |
|
950 | 64 |
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
|
65 |
<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
|
66 |
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
|
67 |
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
|
68 |
for i in xrange(self.cw_rset.rowcount): |
523 | 69 |
self.cell_call(i, 0) |
70 |
self.w(u'</rdf:RDF>\n') |
|
71 |
||
72 |
def cell_call(self, row, col): |
|
3457
0924d0d08d60
[api] __regid__, cw_* and friends
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
73 |
entity = self.cw_rset.complete_entity(row, col) |
6325
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
74 |
# account |
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
75 |
self.w(u'<foaf:OnlineAccount rdf:about="%s">\n' % entity.absolute_url()) |
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
76 |
self.w(u' <foaf:accountName>%s</foaf:accountName>\n' % entity.login) |
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
77 |
self.w(u'</foaf:OnlineAccount>\n') |
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
78 |
# person |
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
79 |
self.w(u'<foaf:Person rdf:about="%s#user">\n' % entity.absolute_url()) |
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
80 |
self.w(u' <foaf:account rdf:resource="%s" />\n' % entity.absolute_url()) |
523 | 81 |
if entity.surname: |
6325
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
82 |
self.w(u'<foaf:familyName>%s</foaf:familyName>\n' |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1977
diff
changeset
|
83 |
% xml_escape(entity.surname)) |
523 | 84 |
if entity.firstname: |
6325
38cfda1ab60f
[views] fix foaf view for CWUser
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5877
diff
changeset
|
85 |
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
|
86 |
% xml_escape(entity.firstname)) |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5426
diff
changeset
|
87 |
emailaddr = entity.cw_adapt_to('IEmailable').get_email() |
523 | 88 |
if emailaddr: |
6339
bdc3dc94d744
[foaf] we should encode email addr: even if we know it should be ascii, nothing prevent from putting something else in (tests at least do it)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6325
diff
changeset
|
89 |
self.w(u'<foaf:mbox_sha1sum>%s</foaf:mbox_sha1sum>\n' |
bdc3dc94d744
[foaf] we should encode email addr: even if we know it should be ascii, nothing prevent from putting something else in (tests at least do it)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6325
diff
changeset
|
90 |
% hashlib.sha1(emailaddr.encode('utf-8')).hexdigest()) |
586 | 91 |
self.w(u'</foaf:Person>\n') |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
92 |
|
5235
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
93 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
94 |
# 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
|
95 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
96 |
_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
|
97 |
_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
|
98 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
99 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
100 |
class CWGroupPrimaryView(tabs.TabbedPrimaryView): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
101 |
__select__ = is_instance('CWGroup') |
5235
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
102 |
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
|
103 |
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
|
104 |
|
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 |
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
|
107 |
__regid__ = 'cwgroup-main' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
108 |
__select__ = tabs.PrimaryTab.__select__ & is_instance('CWGroup') |
5235
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
109 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5237
diff
changeset
|
110 |
def render_entity_attributes(self, entity): |
6582
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6339
diff
changeset
|
111 |
_ = self._cw._ |
5235
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
112 |
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
|
113 |
'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
|
114 |
'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
|
115 |
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
|
116 |
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
|
117 |
_(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
|
118 |
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
|
119 |
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
|
120 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
121 |
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
|
122 |
__regid__ = 'cwgroup-permissions' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
123 |
__select__ = is_instance('CWGroup') |
5235
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
124 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
125 |
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
|
126 |
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
|
127 |
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
|
128 |
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
|
129 |
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
|
130 |
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
|
131 |
'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
|
132 |
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
|
133 |
'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
|
134 |
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
|
135 |
'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
|
136 |
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
|
137 |
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
|
138 |
|
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
139 |
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
|
140 |
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
|
141 |
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
|
142 |
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
|
143 |
if rset: |
5237
10dd0dd78778
[schema view] fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
144 |
self.w(u'<div>%s:</div>' % self._cw.__(access_type + '_permission')) |
10dd0dd78778
[schema view] fixes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
145 |
self.w(u'<div>%s</div><br/>' % self._cw.view('csv', rset, 'null')) |
5235
3a92e6d92a64
ticket #344404, cwgroup primary view improvement, use tabs to display nicely permissions
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5234
diff
changeset
|
146 |
|
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
147 |
class CWGroupInContextView(EntityView): |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
148 |
__regid__ = 'incontext' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5556
diff
changeset
|
149 |
__select__ = is_instance('CWGroup') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
150 |
|
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
151 |
def cell_call(self, row, col): |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
152 |
entity = self.cw_rset.complete_entity(row, col) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4719
diff
changeset
|
153 |
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
|
154 |
entity.absolute_url(), entity.name, entity.printable_value('name'))) |