author | Sandrine Ribeau <sandrine.ribeau@logilab.fr> |
Tue, 06 Apr 2010 12:23:05 +0200 | |
changeset 5234 | e2476d78b060 |
parent 5233 | 673b63953e7a |
child 5235 | 3a92e6d92a64 |
permissions | -rw-r--r-- |
0 | 1 |
"""Specific views for schema related entities |
2 |
||
3 |
:organization: Logilab |
|
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3768
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 |
||
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
10 |
from itertools import cycle |
0 | 11 |
|
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
12 |
from logilab.common.ureports import Section, Table |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2277
diff
changeset
|
13 |
from logilab.mtconverter import xml_escape |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
14 |
from yams import BASE_TYPES, schema2dot as s2d |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
15 |
from yams.buildobjs import DEFAULT_ATTRPERMS |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
16 |
|
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2617
diff
changeset
|
17 |
from cubicweb.selectors import (implements, yes, match_user_groups, |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
18 |
has_related_entities, authenticated_user) |
4434
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4252
diff
changeset
|
19 |
from cubicweb.schema import (META_RTYPES, SCHEMA_TYPES, SYSTEM_RTYPES, |
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4252
diff
changeset
|
20 |
WORKFLOW_TYPES, INTERNAL_TYPES) |
0 | 21 |
from cubicweb.schemaviewer import SchemaViewer |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
22 |
from cubicweb.view import EntityView, StartupView |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
23 |
from cubicweb import tags, uilib |
3768
8c85a2f7f5ad
nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
24 |
from cubicweb.web import action, facet, uicfg |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
25 |
from cubicweb.web.views import TmpFileViewMixin |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
26 |
from cubicweb.web.views import primary, baseviews, tabs, tableview, iprogress |
1151
b20677336ee6
turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
27 |
|
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
28 |
ALWAYS_SKIP_TYPES = BASE_TYPES | SCHEMA_TYPES |
4434
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4252
diff
changeset
|
29 |
SKIP_TYPES = (ALWAYS_SKIP_TYPES | META_RTYPES | SYSTEM_RTYPES | WORKFLOW_TYPES |
4451
65f4665233e6
misc typos found on my way: NameError / SyntaxError / double __select__, <sigh ...>
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
4434
diff
changeset
|
30 |
| INTERNAL_TYPES) |
4434
101344a6ff9b
Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
4252
diff
changeset
|
31 |
SKIP_TYPES.update(set(('CWUser', 'CWGroup'))) |
1151
b20677336ee6
turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
32 |
|
2181
94ca417b9b07
backport stable branch, make schema-security consistent with other schema views changes, uniformize skipmeta/withmeta
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
33 |
def skip_types(req): |
94ca417b9b07
backport stable branch, make schema-security consistent with other schema views changes, uniformize skipmeta/withmeta
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
34 |
if int(req.form.get('skipmeta', True)): |
2387
ea1defea9636
[views] fix some crashers (schema still does not render properly, might be yams side)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2381
diff
changeset
|
35 |
return SKIP_TYPES |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
36 |
return ALWAYS_SKIP_TYPES |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
37 |
|
3768
8c85a2f7f5ad
nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
38 |
_pvs = uicfg.primaryview_section |
8c85a2f7f5ad
nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
39 |
for _action in ('read', 'add', 'update', 'delete'): |
8c85a2f7f5ad
nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
40 |
_pvs.tag_subject_of(('*', '%s_permission' % _action, '*'), 'hidden') |
8c85a2f7f5ad
nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
41 |
_pvs.tag_object_of(('*', '%s_permission' % _action, '*'), 'hidden') |
8c85a2f7f5ad
nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
42 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
43 |
_pvs.tag_object_of(('Workflow', 'workflow_of', 'CWEType'), 'hidden') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
44 |
_pvs.tag_subject_of(('CWEType', 'default_workflow', 'Workflow'), 'hidden') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
45 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
46 |
_pvs.tag_object_of(('*', 'relation_type', 'CWRType'), 'hidden') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
47 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
48 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
49 |
class SecurityViewMixIn(object): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
50 |
"""mixin providing methods to display security information for a entity, |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
51 |
relation or relation definition schema |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
52 |
""" |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
53 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
54 |
def permissions_table(self, erschema, permissions=None): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
55 |
self._cw.add_css('cubicweb.acl.css') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
56 |
w = self.w |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
57 |
_ = self._cw._ |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
58 |
w(u'<table class="schemaInfo">') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
59 |
w(u'<tr><th>%s</th><th>%s</th><th>%s</th></tr>' % ( |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
60 |
_("permission"), _('granted to groups'), _('rql expressions'))) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
61 |
w(u'<table class="schemaInfo">') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
62 |
w(u'<tr><th>%s</th><th>%s</th><th>%s</th></tr>\n' % |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
63 |
(_('permission'), _('granted to groups'), |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
64 |
_('rql expressions'))) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
65 |
for action in erschema.ACTIONS: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
66 |
w(u'<tr><td>%s</td><td>' % _(action)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
67 |
if permissions is None: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
68 |
groups = erschema.get_groups(action) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
69 |
else: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
70 |
groups = permissions[action][1] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
71 |
# XXX get group entity and call it's incontext view |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
72 |
groups = [u'<a class="%s" href="%s">%s</a>' % ( |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
73 |
group, self._cw.build_url('cwgroup/%s' % group), label) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
74 |
for group, label in sorted((_(g), g) for group in groups)] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
75 |
w(u'<br/>'.join(groups)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
76 |
w(u'</td><td>') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
77 |
if permissions is None: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
78 |
rqlexprs = sorted(e.expression for e in erschema.get_rqlexprs(action)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
79 |
else: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
80 |
rqlexprs = permissions[action][1] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
81 |
w(u'<br/>'.join(rqlexprs)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
82 |
w(u'</td></tr>\n') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
83 |
w(u'</table>') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
84 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
85 |
def grouped_permissions_table(self, rschema): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
86 |
# group relation definitions with identical permissions |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
87 |
perms = {} |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
88 |
for rdef in rschema.rdefs.itervalues(): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
89 |
rdef_perms = [] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
90 |
for action in ('read', 'add', 'delete'): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
91 |
groups = sorted(rdef.get_groups(action)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
92 |
exprs = sorted(e.expression for e in rdef.get_rqlexprs(action)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
93 |
rdef_perms.append( (action, (tuple(groups), tuple(exprs))) ) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
94 |
rdef_perms = tuple(rdef_perms) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
95 |
if rdef_perms in perms: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
96 |
perms[rdef_perms].append( (rdef.subject, rdef.object) ) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
97 |
else: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
98 |
perms[rdef_perms] = [(rdef.subject, rdef.object)] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
99 |
# set layout permissions in a table for each group of relation |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
100 |
# definition |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
101 |
w = self.w |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
102 |
w(u'<div style="margin: 0px 1.5em">') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
103 |
tmpl = u'[<strong>%s</strong> %s <strong>%s</strong>]' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
104 |
for perm, rdefs in perms: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
105 |
w(u'<div>%s</div>' % u', '.join( |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
106 |
tmpl % (_(s.type), _(rschema.type), _(o.type)) for s, o in rdefs)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
107 |
# accessing rdef from previous loop by design: only used to get |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
108 |
# ACTIONS |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
109 |
self.permissions_table(rdef, dict(perm)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
110 |
w(u'</div>') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
111 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
112 |
|
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
113 |
# global schema view ########################################################### |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
114 |
|
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
115 |
class SchemaView(tabs.TabsMixin, StartupView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
116 |
__regid__ = 'schema' |
2476
1294a6bdf3bf
application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2436
diff
changeset
|
117 |
title = _('instance schema') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
118 |
tabs = [_('schema-description'), _('schema-image'), _('schema-security')] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
119 |
default_tab = 'schema-description' |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
120 |
|
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
121 |
def call(self): |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
122 |
"""display schema information""" |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
123 |
self.w(u'<h1>%s</h1>' % _('Schema of the data model')) |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
124 |
self.render_tabs(self.tabs, self.default_tab) |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
125 |
|
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
126 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
127 |
class SchemaImageTab(StartupView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
128 |
__regid__ = 'schema-image' |
1151
b20677336ee6
turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
129 |
|
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
130 |
def call(self): |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
131 |
self.w(_(u'<div>This schema of the data model <em>excludes</em> the ' |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
132 |
u'meta-data, but you can also display a <a href="%s">complete ' |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
133 |
u'schema with meta-data</a>.</div>') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
134 |
% xml_escape(self._cw.build_url('view', vid='schemagraph', skipmeta=0))) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
135 |
self.w(u'<img src="%s" alt="%s"/>\n' % ( |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
136 |
xml_escape(self._cw.build_url('view', vid='schemagraph', skipmeta=1)), |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
137 |
self._cw._("graphical representation of the instance'schema"))) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
138 |
|
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
139 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
140 |
class SchemaDescriptionTab(StartupView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
141 |
__regid__ = 'schema-description' |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
142 |
|
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
143 |
def call(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
144 |
rset = self._cw.execute('Any X ORDERBY N WHERE X is CWEType, X name N, ' |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
145 |
'X final FALSE') |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
146 |
self.wview('table', rset, displayfilter=True) |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
147 |
rset = self._cw.execute('Any X ORDERBY N WHERE X is CWRType, X name N, ' |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
148 |
'X final FALSE') |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
149 |
self.wview('table', rset, displayfilter=True) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
150 |
owl_downloadurl = self._cw.build_url('view', vid='owl') |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
151 |
self.w(u'<div><a href="%s">%s</a></div>' % |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
152 |
(owl_downloadurl, self._cw._(u'Download schema as OWL'))) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
153 |
|
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
154 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
155 |
class SchemaPermissionsTab(SecurityViewMixIn, StartupView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
156 |
__regid__ = 'schema-security' |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
157 |
__select__ = StartupView.__select__ & match_user_groups('managers') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
158 |
|
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
159 |
def call(self, display_relations=True): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
160 |
self._cw.add_css('cubicweb.acl.css') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
161 |
skiptypes = skip_types(self._cw) |
4045
f4a52abb6f4f
cw 3.6 api update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
4023
diff
changeset
|
162 |
schema = self._cw.vreg.schema |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
163 |
# compute entities |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
164 |
entities = sorted(eschema for eschema in schema.entities() |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3555
diff
changeset
|
165 |
if not (eschema.final or eschema in skiptypes)) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
166 |
# compute relations |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
167 |
if display_relations: |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
168 |
relations = sorted(rschema for rschema in schema.relations() |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3555
diff
changeset
|
169 |
if not (rschema.final |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
170 |
or rschema in skiptypes |
2617
89c62b855f2e
[R schema hooks] rename META_RELATIONS_TYPES into META_RTYPES, use it and other schema consts to avoid errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2476
diff
changeset
|
171 |
or rschema in META_RTYPES)) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
172 |
else: |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
173 |
relations = [] |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
174 |
# index |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
175 |
_ = self._cw._ |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
176 |
url = xml_escape(self._cw.build_url('schema')) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
177 |
self.w(u'<div id="schema_security">') |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
178 |
self.w(u'<h2 class="schema">%s</h2>' % _('Index')) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
179 |
self.w(u'<h4 id="entities">%s</h4>' % _('Entity types')) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
180 |
ents = [] |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
181 |
for eschema in sorted(entities): |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
182 |
ents.append(u'<a class="grey" href="%s#%s">%s</a>' % ( |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
183 |
url, eschema.type, eschema.type)) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
184 |
self.w(u', '.join(ents)) |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
185 |
self.w(u'<h4 id="relations">%s</h4>' % _('Relation types')) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
186 |
rels = [] |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
187 |
for rschema in sorted(relations): |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
188 |
rels.append(u'<a class="grey" href="%s#%s">%s</a>' % ( |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
189 |
url , rschema.type, rschema.type)) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
190 |
self.w(u', '.join(rels)) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
191 |
# permissions tables |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
192 |
self.display_entities(entities) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
193 |
if relations: |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
194 |
self.display_relations(relations) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
195 |
self.w(u'</div>') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
196 |
|
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
197 |
def has_non_default_perms(self, rdef): |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
198 |
"""return true if the given *attribute* relation definition has custom |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
199 |
permission |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
200 |
""" |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
201 |
for action in rdef.ACTIONS: |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
202 |
def_rqlexprs = [] |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
203 |
def_groups = [] |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
204 |
for perm in DEFAULT_ATTRPERMS[action]: |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
205 |
if not isinstance(perm, basestring): |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
206 |
def_rqlexprs.append(perm.expression) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
207 |
else: |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
208 |
def_groups.append(perm) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
209 |
rqlexprs = [rql.expression for rql in rdef.get_rqlexprs(action)] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
210 |
groups = rdef.get_groups(action) |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
211 |
if groups != frozenset(def_groups) or \ |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
212 |
frozenset(rqlexprs) != frozenset(def_rqlexprs): |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
213 |
return True |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
214 |
return False |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
215 |
|
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
216 |
def display_entities(self, entities): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
217 |
_ = self._cw._ |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
218 |
url = xml_escape(self._cw.build_url('schema')) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
219 |
self.w(u'<h2 id="entities" class="schema">%s</h2>' % _('Permissions for entity types')) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
220 |
for eschema in entities: |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
221 |
self.w(u'<h3 id="%s" class="schema"><a href="%s">%s (%s)</a> ' % ( |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
222 |
eschema.type, self._cw.build_url('cwetype/%s' % eschema.type), |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
223 |
eschema.type, _(eschema.type))) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
224 |
self.w(u'<a href="%s#schema_security"><img src="%s" alt="%s"/></a>' % ( |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
225 |
url, self._cw.external_resource('UP_ICON'), _('up'))) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
226 |
self.w(u'</h3>') |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
227 |
self.w(u'<div style="margin: 0px 1.5em">') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
228 |
self.permissions_table(eschema) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
229 |
# display entity attributes only if they have some permissions modified |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
230 |
modified_attrs = [] |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
231 |
for attr, etype in eschema.attribute_definitions(): |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
232 |
rdef = eschema.rdef(attr) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
233 |
if attr not in META_RTYPES and self.has_non_default_perms(rdef): |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
234 |
modified_attrs.append(rdef) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
235 |
if modified_attrs: |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
236 |
self.w(u'<h4>%s</h4>' % _('Attributes with non default permissions:')) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
237 |
self.w(u'</div>') |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
238 |
self.w(u'<div style="margin: 0px 6em">') |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
239 |
for rdef in modified_attrs: |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
240 |
attrtype = str(rdef.rtype) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
241 |
self.w(u'<h4 class="schema">%s (%s)</h4> ' % (attrtype, _(attrtype))) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
242 |
self.permissions_table(rdef) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
243 |
self.w(u'</div>') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
244 |
|
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
245 |
def display_relations(self, relations): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
246 |
_ = self._cw._ |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
247 |
url = xml_escape(self._cw.build_url('schema')) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
248 |
self.w(u'<h2 id="relations" class="schema">%s</h2>' % _('Permissions for relations')) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
249 |
for rschema in relations: |
5232
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
250 |
self.w(u'<h3 id="%s" class="schema"><a href="%s">%s (%s)</a> ' % ( |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
251 |
rschema.type, self._cw.build_url('cwrtype/%s' % rschema.type), |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
252 |
rschema.type, _(rschema.type))) |
78c1a531f7b3
ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5224
diff
changeset
|
253 |
self.w(u'<a href="%s#schema_security"><img src="%s" alt="%s"/></a>' % ( |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
254 |
url, self._cw.external_resource('UP_ICON'), _('up'))) |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
255 |
self.w(u'</h3>') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
256 |
self.grouped_permissions_table(rschema) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
257 |
|
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
258 |
|
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
259 |
# CWEType ###################################################################### |
0 | 260 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
261 |
# register msgid generated in entity relations tables |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
262 |
_('i18ncard_1'), _('i18ncard_?'), _('i18ncard_+'), _('i18ncard_*') |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
263 |
|
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
264 |
class CWETypePrimaryView(tabs.TabbedPrimaryView): |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
265 |
__select__ = implements('CWEType') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
266 |
tabs = [_('cwetype-description'), _('cwetype-box'), _('cwetype-workflow'), |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
267 |
_('cwetype-views'), _('cwetype-permissions')] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
268 |
default_tab = 'cwetype-description' |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
269 |
|
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
270 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
271 |
class CWETypeDescriptionTab(tabs.PrimaryTab): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
272 |
__regid__ = 'cwetype-description' |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
273 |
__select__ = tabs.PrimaryTab.__select__ & implements('CWEType') |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
274 |
|
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
275 |
def render_entity_attributes(self, entity, siderelations=None): |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
276 |
self.w(u'<div>%s</div>' % xml_escape(entity.description or u'')) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
277 |
# entity schema image |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
278 |
url = entity.absolute_url(vid='schemagraph') |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
279 |
self.w(u'<img src="%s" alt="%s"/>' % ( |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
280 |
xml_escape(url), |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
281 |
xml_escape(self._cw._('graphical schema for %s') % entity.name))) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
282 |
# entity schema attributes |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
283 |
self.w(u'<h2>%s</h2>' % _('Attributes')) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
284 |
rset = self._cw.execute( |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
285 |
'Any A,F,DE,D,C, I,J,A ORDERBY AA WHERE A is CWAttribute, ' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
286 |
'A ordernum AA, A defaultval D, A description DE, A cardinality C, ' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
287 |
'A fulltextindexed I, A internationalizable J, ' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
288 |
'A relation_type R, R name N, A to_entity O, O name F, ' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
289 |
'A from_entity S, S eid %(x)s', |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
290 |
{'x': entity.eid}) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
291 |
self.wview('table', rset, 'null', |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
292 |
cellvids={0: 'rdef-name-cell', |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
293 |
4: 'etype-attr-cardinality-cell', |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
294 |
7: 'rdef-constraints-cell'}, |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
295 |
headers=(_(u'name'), _(u'type'), _(u'description'), |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
296 |
_(u'default value'), _(u'required'), |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
297 |
_(u'fulltext indexed'), _(u'internationalizable'), |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
298 |
_(u'constraints')), |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
299 |
mainindex=0) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
300 |
# entity schema relations |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
301 |
self.w(u'<h2>%s</h2>' % _('Relations')) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
302 |
rset = self._cw.execute( |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
303 |
'Any A, TT, "i18ncard_"+SUBSTRING(C, 1, 1),K,D,A,A,RN,TTN ORDERBY RN ' |
4971
20bffbba7a5a
don't use optional on final relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4571
diff
changeset
|
304 |
'WHERE A is CWRelation, A description D, A composite K, ' |
2228
7e85d0169911
some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
305 |
'A relation_type R, R name RN, A to_entity TT, TT name TTN, ' |
7e85d0169911
some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
306 |
'A cardinality C, A from_entity S, S eid %(x)s', |
7e85d0169911
some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
307 |
{'x': entity.eid}) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
308 |
if rset: |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
309 |
self.w(u'<h5>%s %s</h5>' % (entity.name, _('is subject of:'))) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
310 |
self.wview('table', rset, 'null', |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
311 |
cellvids={0: 'rdef-name-cell', |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
312 |
2: 'etype-rel-cardinality-cell', |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
313 |
5: 'rdef-constraints-cell'}, |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
314 |
headers=(_(u'name'), _(u'object type'), _(u'cardinality'), |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
315 |
_(u'composite'), _(u'description'), |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
316 |
_(u'constraints'), _(u'relation direction')), |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
317 |
displaycols=range(5), mainindex=0) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
318 |
self.w(u'<br/>') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
319 |
rset = self._cw.execute( |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
320 |
'Any A, TT, "i18ncard_"+SUBSTRING(C, 2, 1),K,D,A,A,RN,TTN ORDERBY RN ' |
4971
20bffbba7a5a
don't use optional on final relation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4571
diff
changeset
|
321 |
'WHERE A is CWRelation, A description D, A composite K, ' |
2228
7e85d0169911
some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
322 |
'A relation_type R, R name RN, A from_entity TT, TT name TTN, ' |
7e85d0169911
some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
323 |
'A cardinality C, A to_entity O, O eid %(x)s', |
7e85d0169911
some enhancements: link to relation/target type, remove to be deprecated meta, one table for subject relations, another for object relations
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2172
diff
changeset
|
324 |
{'x': entity.eid}) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
325 |
if rset: |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
326 |
self.w(u'<h5>%s %s</h5>' % (entity.name, _('is object of:'))) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
327 |
self.wview('table', rset, 'null', |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
328 |
cellvids={0: 'rdef-object-name-cell', |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
329 |
2: 'etype-rel-cardinality-cell', |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
330 |
5: 'rdef-constraints-cell'}, |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
331 |
headers=(_(u'name'), _(u'subject type'), _(u'cardinality'), |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
332 |
_(u'composite'), _(u'description'), |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
333 |
_(u'constraints'), _(u'relation direction')), |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
334 |
displaycols=range(5), mainindex=0) |
0 | 335 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
336 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
337 |
class CWETypeAttributeCardinalityCell(baseviews.FinalView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
338 |
__regid__ = 'etype-attr-cardinality-cell' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
339 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
340 |
def cell_call(self, row, col): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
341 |
if self.cw_rset.rows[row][col][0] == '1': |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
342 |
self.w(self._cw._(u'required')) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
343 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
344 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
345 |
class CWETypeRelationCardinalityCell(baseviews.FinalView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
346 |
__regid__ = 'etype-rel-cardinality-cell' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
347 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
348 |
def cell_call(self, row, col): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
349 |
self.w(self._cw._(self.cw_rset.rows[row][col])) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
350 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
351 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
352 |
class CWETypeBoxTab(EntityView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
353 |
__regid__ = 'cwetype-box' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
354 |
__select__ = implements('CWEType') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
355 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
356 |
def cell_call(self, row, col): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
357 |
viewer = SchemaViewer(self._cw) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
358 |
entity = self.cw_rset.get_entity(row, col) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
359 |
eschema = self._cw.vreg.schema.eschema(entity.name) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
360 |
layout = viewer.visit_entityschema(eschema) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
361 |
self.w(uilib.ureport_as_html(layout)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
362 |
self.w(u'<br class="clear"/>') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
363 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
364 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
365 |
class CWETypePermTab(SecurityViewMixIn, EntityView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
366 |
__regid__ = 'cwetype-permissions' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
367 |
__select__ = implements('CWEType') & authenticated_user() |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
368 |
|
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
369 |
def cell_call(self, row, col): |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
370 |
self._cw.add_css('cubicweb.acl.css') |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
371 |
entity = self.cw_rset.get_entity(row, col) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
372 |
eschema = self._cw.vreg.schema.eschema(entity.name) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
373 |
self.w(u'<div style="margin: 0px 1.5em">') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
374 |
self.permissions_table(eschema) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
375 |
self.w(u'<h4>%s</h4>' % _('attributes permissions:').capitalize()) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
376 |
for attr, etype in eschema.attribute_definitions(): |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
377 |
if attr not in META_RTYPES: |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
378 |
rdef = eschema.rdef(attr) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
379 |
attrtype = str(rdef.rtype) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
380 |
self.w(u'<h4 class="schema">%s (%s)</h4> ' % (attrtype, _(attrtype))) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
381 |
self.permissions_table(rdef) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
382 |
self.w(u'</div>') |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
383 |
|
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2617
diff
changeset
|
384 |
|
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
385 |
class CWETypeWorkflowTab(EntityView): |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
386 |
__regid__ = 'cwetype-workflow' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
387 |
__select__ = (implements('CWEType') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
388 |
& has_related_entities('workflow_of', 'object')) |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
389 |
|
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
390 |
def cell_call(self, row, col): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
391 |
entity = self.cw_rset.get_entity(row, col) |
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2617
diff
changeset
|
392 |
if entity.default_workflow: |
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2617
diff
changeset
|
393 |
wf = entity.default_workflow[0] |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
394 |
if len(entity.reverse_workflow_of) > 1: |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
395 |
self.w(u'<h1>%s (%s)</h1>' |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
396 |
% (wf.name, self._cw._('default_workflow'))) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
397 |
self.display_workflow(wf) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
398 |
defaultwfeid = wf.eid |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
399 |
else: |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
400 |
self.w(u'<div class="error">%s</div>' |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
401 |
% self._cw._('There is no default workflow')) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
402 |
defaultwfeid = None |
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2617
diff
changeset
|
403 |
for altwf in entity.reverse_workflow_of: |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
404 |
if altwf.eid == defaultwfeid: |
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2617
diff
changeset
|
405 |
continue |
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2617
diff
changeset
|
406 |
self.w(u'<h1>%s</h1>' % altwf.name) |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
407 |
self.display_workflow(altwf) |
3215
bf30ab5ba6ee
fix workflow graph views and tabs for the new wf system, remove useless view and action (actually useless since introduction of tabbed entity type view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2617
diff
changeset
|
408 |
|
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
409 |
def display_workflow(self, wf): |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
410 |
self.w(wf.view('wfgraph')) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
411 |
self.w('<a href="%s">%s</a>' % ( |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
412 |
wf.absolute_url(), self._cw._('more info about this workflow'))) |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
413 |
|
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
414 |
|
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
415 |
class CWETypeViewsTab(EntityView): |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
416 |
__regid__ = 'cwetype-views' |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
417 |
__select__ = EntityView.__select__ & implements('CWEType') |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
418 |
|
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
419 |
def cell_call(self, row, col): |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
420 |
entity = self.cw_rset.get_entity(row, col) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
421 |
etype = entity.name |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
422 |
_ = self._cw._ |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
423 |
# possible views for this entity type |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
424 |
views = [(_(view.title),) for view in self.possible_views(etype)] |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
425 |
self.wview('pyvaltable', pyvalue=views, headers=(_(u'views'),)) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
426 |
|
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
427 |
def possible_views(self, etype): |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
428 |
rset = self._cw.etype_rset(etype) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
429 |
return [v for v in self._cw.vreg['views'].possible_views(self._cw, rset) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
430 |
if v.category != 'startupview'] |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
431 |
|
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
432 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
433 |
class CWETypeOneLineView(baseviews.OneLineView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
434 |
__select__ = implements('CWEType') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
435 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
436 |
def cell_call(self, row, col, **kwargs): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
437 |
entity = self.cw_rset.get_entity(row, col) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
438 |
if entity.final: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
439 |
self.w(u'<em class="finalentity">') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
440 |
super(CWETypeOneLineView, self).cell_call(row, col, **kwargs) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
441 |
if entity.final: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
442 |
self.w(u'</em>') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
443 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
444 |
|
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
445 |
# CWRType ###################################################################### |
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
446 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
447 |
class CWRTypePrimaryView(tabs.TabbedPrimaryView): |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
448 |
__select__ = implements('CWRType') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
449 |
tabs = [_('cwrtype-description'), _('cwrtype-permissions')] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
450 |
default_tab = 'cwrtype-description' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
451 |
|
0 | 452 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
453 |
class CWRTypeDescriptionTab(tabs.PrimaryTab): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
454 |
__regid__ = 'cwrtype-description' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
455 |
__select__ = implements('CWRType') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
456 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
457 |
def render_entity_attributes(self, entity, siderelations=None): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
458 |
self.w(u'<div>%s</div>' % xml_escape(entity.description or u'')) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
459 |
rschema = self._cw.vreg.schema.rschema(entity.name) |
3689
deb13e88e037
follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3555
diff
changeset
|
460 |
if not rschema.final: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
461 |
msg = self._cw._('graphical schema for %s') % entity.name |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
462 |
self.w(tags.img(src=entity.absolute_url(vid='schemagraph'), |
1556 | 463 |
alt=msg)) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
464 |
rset = self._cw.execute('Any R,ST,OT,C,CC,R WHERE R is CWRelation, ' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
465 |
'R relation_type RT, RT eid %(x)s, ' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
466 |
'R from_type ST, R to_type OT, ' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
467 |
'R cardinality C, R composite CC', |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
468 |
{'x': entity.eid}) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
469 |
self.wview('table', rset, 'null', |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
470 |
headers=(_(u'relation'), _(u'subject'), _(u'object'), |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
471 |
_(u'cardinality'), _(u'composite'), |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
472 |
_(u'constraints')), |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
473 |
cellvids={5: 'rdef-constraints-cell'}) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
474 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
475 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
476 |
class CWRTypePermTab(SecurityViewMixIn, EntityView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
477 |
__regid__ = 'cwrtype-permissions' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
478 |
__select__ = implements('CWRType') & authenticated_user() |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
479 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
480 |
def cell_call(self, row, col): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
481 |
self._cw.add_css('cubicweb.acl.css') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
482 |
entity = self.cw_rset.get_entity(row, col) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
483 |
rschema = self._cw.vreg.schema.rschema(entity.name) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
484 |
self.grouped_permissions_table(rschema) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
485 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
486 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
487 |
# CWAttribute / CWRelation ##################################################### |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
488 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
489 |
class CWRDEFPrimaryView(tabs.TabbedPrimaryView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
490 |
__select__ = implements('CWRelation', 'CWAttribute') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
491 |
tabs = [_('cwrdef-description'), _('cwrdef-permissions')] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
492 |
default_tab = 'cwrdef-description' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
493 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
494 |
class CWRDEFDescriptionTab(tabs.PrimaryTab): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
495 |
__regid__ = 'cwrdef-description' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
496 |
__select__ = implements('CWRelation', 'CWAttribute') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
497 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
498 |
class CWRDEFPermTab(SecurityViewMixIn, EntityView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
499 |
__regid__ = 'cwrdef-permissions' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
500 |
__select__ = implements('CWRelation', 'CWAttribute') & authenticated_user() |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
501 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
502 |
def cell_call(self, row, col): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
503 |
entity = self.cw_rset.get_entity(row, col) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
504 |
rschema = self._cw.vreg.schema.rschema(entity.rtype.name) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
505 |
rdef = rschema.rdefs[(entity.stype.name, entity.otype.name)] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
506 |
self.display_permission(rdef) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
507 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
508 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
509 |
class CWRDEFNameView(tableview.CellView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
510 |
"""display relation name and its translation only in a cell view, link to |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
511 |
relation definition's primary view (for use in entity type relations table |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
512 |
for instance) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
513 |
""" |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
514 |
__regid__ = 'rdef-name-cell' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
515 |
__select__ = implements('CWRelation', 'CWAttribute') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
516 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
517 |
def cell_content(self, entity): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
518 |
rtype = entity.relation_type[0].name |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
519 |
# XXX use contect entity + pgettext |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
520 |
return u'%s (%s)' % (rtype, self._cw._(rtype)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
521 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
522 |
class CWRDEFObjectNameView(tableview.CellView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
523 |
"""same as CWRDEFNameView but when the context is the object entity |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
524 |
""" |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
525 |
__regid__ = 'rdef-object-name-cell' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
526 |
__select__ = implements('CWRelation', 'CWAttribute') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
527 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
528 |
def cell_content(self, entity): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
529 |
rtype = entity.relation_type[0].name |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
530 |
# XXX use contect entity + pgettext |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
531 |
return u'%s (%s)' % (rtype, self._cw.__(rtype + '_object')) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
532 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
533 |
class CWRDEFConstraintsCell(EntityView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
534 |
__regid__ = 'rdef-constraints-cell' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
535 |
__select__ = implements('CWAttribute', 'CWRelation') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
536 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
537 |
def cell_call(self, row, col): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
538 |
entity = self.cw_rset.get_entity(row, col) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
539 |
rschema = self._cw.vreg.schema.rschema(entity.rtype.name) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
540 |
rdef = rschema.rdefs[(entity.stype.name, entity.otype.name)] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
541 |
constraints = [xml_escape(str(c)) for c in getattr(rdef, 'constraints')] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
542 |
self.w(u', '.join(constraints)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
543 |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
544 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
545 |
# schema images ############################################################### |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
546 |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
547 |
class RestrictedSchemaVisitorMixIn(object): |
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
548 |
def __init__(self, req, *args, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
549 |
self._cw = req |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
550 |
super(RestrictedSchemaVisitorMixIn, self).__init__(*args, **kwargs) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
551 |
|
2387
ea1defea9636
[views] fix some crashers (schema still does not render properly, might be yams side)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2381
diff
changeset
|
552 |
def should_display_schema(self, rschema): |
ea1defea9636
[views] fix some crashers (schema still does not render properly, might be yams side)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
2381
diff
changeset
|
553 |
return (super(RestrictedSchemaVisitorMixIn, self).should_display_schema(rschema) |
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
554 |
and rschema.may_have_permission('read', self._cw)) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
555 |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3768
diff
changeset
|
556 |
def should_display_attr(self, eschema, rschema): |
4108
f9c51250480a
schema view fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4045
diff
changeset
|
557 |
return (super(RestrictedSchemaVisitorMixIn, self).should_display_attr(eschema, rschema) |
3890
d7a270f50f54
backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
558 |
and eschema.rdef(rschema).may_have_permission('read', self._cw)) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
559 |
|
0 | 560 |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
561 |
class FullSchemaVisitor(RestrictedSchemaVisitorMixIn, s2d.FullSchemaVisitor): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
562 |
pass |
0 | 563 |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
564 |
class OneHopESchemaVisitor(RestrictedSchemaVisitorMixIn, |
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
565 |
s2d.OneHopESchemaVisitor): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
566 |
pass |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
567 |
|
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
568 |
class OneHopRSchemaVisitor(RestrictedSchemaVisitorMixIn, |
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
569 |
s2d.OneHopRSchemaVisitor): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
570 |
pass |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
571 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
572 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
573 |
class SchemaImageView(TmpFileViewMixin, StartupView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
574 |
__regid__ = 'schemagraph' |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
575 |
content_type = 'image/png' |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
576 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
577 |
def _generate(self, tmpfile): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
578 |
"""display global schema information""" |
4045
f4a52abb6f4f
cw 3.6 api update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
4023
diff
changeset
|
579 |
visitor = FullSchemaVisitor(self._cw, self._cw.vreg.schema, |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
580 |
skiptypes=skip_types(self._cw)) |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
581 |
s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
582 |
|
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
583 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
584 |
class CWETypeSchemaImageView(TmpFileViewMixin, EntityView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
585 |
__regid__ = 'schemagraph' |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
586 |
__select__ = implements('CWEType') |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
587 |
content_type = 'image/png' |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
588 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
589 |
def _generate(self, tmpfile): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
590 |
"""display schema information for an entity""" |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
591 |
entity = self.cw_rset.get_entity(self.cw_row, self.cw_col) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
592 |
eschema = self._cw.vreg.schema.eschema(entity.name) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
593 |
visitor = OneHopESchemaVisitor(self._cw, eschema, |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
594 |
skiptypes=skip_types(self._cw)) |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
595 |
s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
596 |
|
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
597 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
598 |
class CWRTypeSchemaImageView(CWETypeSchemaImageView): |
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
599 |
__select__ = implements('CWRType') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
600 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
601 |
def _generate(self, tmpfile): |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
602 |
"""display schema information for an entity""" |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
603 |
entity = self.cw_rset.get_entity(self.cw_row, self.cw_col) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
604 |
rschema = self._cw.vreg.schema.rschema(entity.name) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
605 |
visitor = OneHopRSchemaVisitor(self._cw, rschema) |
2126
a25859917ccc
stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1998
diff
changeset
|
606 |
s2d.schema2dot(outputfile=tmpfile, visitor=visitor) |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
607 |
|
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
608 |
|
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
609 |
# misc: facets, actions ######################################################## |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
610 |
|
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
611 |
class CWFinalFacet(facet.AttributeFacet): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
612 |
__regid__ = 'cwfinal-facet' |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
613 |
__select__ = facet.AttributeFacet.__select__ & implements('CWEType', 'CWRType') |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
614 |
rtype = 'final' |
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
615 |
|
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
616 |
class ViewSchemaAction(action.Action): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
617 |
__regid__ = 'schema' |
2436
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
618 |
__select__ = yes() |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
619 |
|
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
620 |
title = _("site schema") |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
621 |
category = 'siteactions' |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
622 |
order = 30 |
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
623 |
|
44b2eea35efa
move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2387
diff
changeset
|
624 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
625 |
return self._cw.build_url(self.__regid__) |