author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 10 Jun 2016 13:21:13 +0200 | |
changeset 11294 | cd1183a65ebb |
parent 10981 | 45bc791275b4 |
permissions | -rw-r--r-- |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7845
diff
changeset
|
1 |
# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
2 |
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
3 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
4 |
# This file is part of CubicWeb. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
5 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
6 |
# CubicWeb is free software: you can redistribute it and/or modify it under the |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
7 |
# terms of the GNU Lesser General Public License as published by the Free |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
8 |
# Software Foundation, either version 2.1 of the License, or (at your option) |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
9 |
# any later version. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
10 |
# |
5424
8ecbcbff9777
replace logilab-common by CubicWeb in disclaimer
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5421
diff
changeset
|
11 |
# CubicWeb is distributed in the hope that it will be useful, but WITHOUT |
5421
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
12 |
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
13 |
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
14 |
# details. |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
15 |
# |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
16 |
# You should have received a copy of the GNU Lesser General Public License along |
8167de96c523
proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
17 |
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
18 |
"""Specific views for schema related entities""" |
0 | 19 |
|
20 |
__docformat__ = "restructuredtext en" |
|
10666
7f6b5f023884
[py3k] replace '_ = unicode' in global scope (closes #7589459)
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10663
diff
changeset
|
21 |
from cubicweb import _ |
0 | 22 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
23 |
from itertools import cycle |
0 | 24 |
|
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
25 |
import tempfile |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
26 |
import os, os.path as osp |
9383
7b3fa5a7a5a3
[views/dot] use an inlined svg for schema and workflow graphs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
27 |
import codecs |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
28 |
|
10740
59e89db3a67d
[web] unicode → six.text_type
Julien Cristau <julien.cristau@logilab.fr>
parents:
10668
diff
changeset
|
29 |
from six import text_type |
59e89db3a67d
[web] unicode → six.text_type
Julien Cristau <julien.cristau@logilab.fr>
parents:
10668
diff
changeset
|
30 |
|
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
31 |
from logilab.common.graph import GraphGenerator, DotBackend |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
32 |
from logilab.common.ureports import Section, Table |
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7845
diff
changeset
|
33 |
from logilab.common.registry import yes |
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2277
diff
changeset
|
34 |
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
|
35 |
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
|
36 |
from yams.buildobjs import DEFAULT_ATTRPERMS |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
37 |
|
8190
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7845
diff
changeset
|
38 |
from cubicweb.predicates import (is_instance, match_user_groups, match_kwargs, |
2a3c1b787688
[vreg] move base registry implementation to logilab.common. Closes #1916014
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7845
diff
changeset
|
39 |
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
|
40 |
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
|
41 |
WORKFLOW_TYPES, INTERNAL_TYPES) |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
42 |
from cubicweb.utils import make_uid |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
43 |
from cubicweb.view import EntityView, StartupView |
4023
eae23c40627a
drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3890
diff
changeset
|
44 |
from cubicweb import tags, uilib |
8665
e65af61bde7d
[uicfg] uicfg.py moves from web/ to web/views/ (prepares #2406609)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8216
diff
changeset
|
45 |
from cubicweb.web import action, facet, schemaviewer |
e65af61bde7d
[uicfg] uicfg.py moves from web/ to web/views/ (prepares #2406609)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
8216
diff
changeset
|
46 |
from cubicweb.web.views import uicfg, primary, baseviews, tabs, tableview, ibreadcrumbs |
1151
b20677336ee6
turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
47 |
|
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
|
48 |
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
|
49 |
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
|
50 |
| INTERNAL_TYPES) |
6827
e730b401f00e
[ui tweaks] fix default ui
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6582
diff
changeset
|
51 |
SKIP_TYPES.update(set(('CWUser', 'CWGroup', 'EmailAddress', 'Bookmark'))) |
1151
b20677336ee6
turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
52 |
|
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
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
|
57 |
|
3768
8c85a2f7f5ad
nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
58 |
_pvs = uicfg.primaryview_section |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
59 |
_pvdc = uicfg.primaryview_display_ctrl |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
60 |
|
3768
8c85a2f7f5ad
nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
61 |
for _action in ('read', 'add', 'update', 'delete'): |
8c85a2f7f5ad
nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3689
diff
changeset
|
62 |
_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
|
63 |
_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
|
64 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
65 |
for _etype in ('CWEType', 'CWRType', 'CWAttribute', 'CWRelation'): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
66 |
_pvdc.tag_attribute((_etype, 'description'), {'showlabel': False}) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
67 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
68 |
_pvs.tag_attribute(('CWEType', 'name'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
69 |
_pvs.tag_attribute(('CWEType', 'final'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
70 |
_pvs.tag_object_of(('*', 'workflow_of', 'CWEType'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
71 |
_pvs.tag_subject_of(('CWEType', 'default_workflow', '*'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
72 |
_pvs.tag_object_of(('*', 'specializes', 'CWEType'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
73 |
_pvs.tag_subject_of(('CWEType', 'specializes', '*'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
74 |
_pvs.tag_object_of(('*', 'from_entity', 'CWEType'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
75 |
_pvs.tag_object_of(('*', 'to_entity', 'CWEType'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
76 |
|
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
77 |
_pvs.tag_attribute(('CWRType', 'name'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
78 |
_pvs.tag_attribute(('CWRType', 'final'), 'hidden') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
79 |
_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
|
80 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
81 |
_pvs.tag_subject_of(('CWAttribute', 'constrained_by', '*'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
82 |
_pvs.tag_subject_of(('CWRelation', 'constrained_by', '*'), 'hidden') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
83 |
|
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
84 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
85 |
class SecurityViewMixIn(object): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
86 |
"""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
|
87 |
relation or relation definition schema |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
88 |
""" |
10405
7b27a7443180
[views/schema] extract a hardcoded css class attribute
Aurelien Campeas <aurelien.campeas@pythonian.fr>
parents:
9383
diff
changeset
|
89 |
cssclass = "listing schemaInfo" |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
90 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
91 |
def permissions_table(self, erschema, permissions=None): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
92 |
self._cw.add_css('cubicweb.acl.css') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
93 |
w = self.w |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
94 |
_ = self._cw._ |
10405
7b27a7443180
[views/schema] extract a hardcoded css class attribute
Aurelien Campeas <aurelien.campeas@pythonian.fr>
parents:
9383
diff
changeset
|
95 |
w(u'<table class="%s">' % self.cssclass) |
5823
8a6c15e2e8b0
[schema view] width isn't in authorized th attribute in xhtml DTD. katia, please do it another way.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5822
diff
changeset
|
96 |
w(u'<tr><th>%s</th><th>%s</th><th>%s</th></tr>' % ( |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
97 |
_("permission"), _('granted to groups'), _('rql expressions'))) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
98 |
for action in erschema.ACTIONS: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
99 |
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
|
100 |
if permissions is None: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
101 |
groups = erschema.get_groups(action) |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
102 |
rqlexprs = sorted(e.expression for e in erschema.get_rqlexprs(action)) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
103 |
else: |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
104 |
groups = permissions[action][0] |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
105 |
rqlexprs = permissions[action][1] |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
106 |
# 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
|
107 |
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
|
108 |
group, self._cw.build_url('cwgroup/%s' % group), label) |
7811
c468ff909e98
[schema view] fix label/name inversion leading to wrong css class / group url depending on user's language
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7782
diff
changeset
|
109 |
for label, group in sorted((_(g), g) for g in groups)] |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
110 |
w(u'<br/>'.join(groups)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
111 |
w(u'</td><td>') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
112 |
w(u'<br/>'.join(rqlexprs)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
113 |
w(u'</td></tr>\n') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
114 |
w(u'</table>') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
115 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
116 |
def grouped_permissions_table(self, rschema): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
117 |
# group relation definitions with identical permissions |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
118 |
perms = {} |
10663
54b8a1f249fb
[py3k] dict.itervalues → dict.values
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10662
diff
changeset
|
119 |
for rdef in rschema.rdefs.values(): |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
120 |
rdef_perms = [] |
6084
c764be84700d
[schema view] use rdef.ACTIONS, attribute/relation don't use the same actions permission, that causes a crash for attribute rdefs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6045
diff
changeset
|
121 |
for action in rdef.ACTIONS: |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
122 |
groups = sorted(rdef.get_groups(action)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
123 |
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
|
124 |
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
|
125 |
rdef_perms = tuple(rdef_perms) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
126 |
if rdef_perms in perms: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
127 |
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
|
128 |
else: |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
129 |
perms[rdef_perms] = [(rdef.subject, rdef.object)] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
130 |
# 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
|
131 |
# definition |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
132 |
w = self.w |
6582
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6084
diff
changeset
|
133 |
_ = self._cw._ |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
134 |
w(u'<div style="margin: 0px 1.5em">') |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
135 |
tmpl = u'<strong>%s</strong> %s <strong>%s</strong>' |
10662
10942ed172de
[py3k] dict.iteritems → dict.items
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10405
diff
changeset
|
136 |
for perm, rdefs in perms.items(): |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
137 |
w(u'<div>%s</div>' % u', '.join( |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
138 |
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
|
139 |
# 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
|
140 |
# ACTIONS |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
141 |
self.permissions_table(rdef, dict(perm)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
142 |
w(u'</div>') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
143 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
144 |
|
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 |
# 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
|
146 |
|
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
|
147 |
class SchemaView(tabs.TabsMixin, StartupView): |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
148 |
"""display schema information (graphically, listing tables...) in tabs""" |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
149 |
__regid__ = 'schema' |
7810
21683b1975e3
[i18n] tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7797
diff
changeset
|
150 |
title = _('data model schema') |
5525
c4eee9921e19
[views] tab schema image renamed to schema diagram
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
151 |
tabs = [_('schema-diagram'), _('schema-entity-types'), |
6854 | 152 |
_('schema-relation-types')] |
5525
c4eee9921e19
[views] tab schema image renamed to schema diagram
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
153 |
default_tab = 'schema-diagram' |
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
|
154 |
|
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
|
155 |
def call(self): |
7810
21683b1975e3
[i18n] tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7797
diff
changeset
|
156 |
self.w(u'<h1>%s</h1>' % self._cw._(self.title)) |
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 |
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
|
158 |
|
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 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
160 |
class SchemaImageTab(StartupView): |
5525
c4eee9921e19
[views] tab schema image renamed to schema diagram
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
5426
diff
changeset
|
161 |
__regid__ = 'schema-diagram' |
1151
b20677336ee6
turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents:
1132
diff
changeset
|
162 |
|
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 |
def call(self): |
6582
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6084
diff
changeset
|
164 |
_ = self._cw._ |
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6084
diff
changeset
|
165 |
self.w(self._cw._( |
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6084
diff
changeset
|
166 |
u'<div>This schema of the data model <em>excludes</em> the ' |
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6084
diff
changeset
|
167 |
'meta-data, but you can also display a <a href="%s">complete ' |
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6084
diff
changeset
|
168 |
'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
|
169 |
% xml_escape(self._cw.build_url('view', vid='schemagraph', skipmeta=0))) |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
170 |
self.w(u'<div><a href="%s">%s</a></div>' % |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
171 |
(self._cw.build_url('view', vid='owl'), |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
172 |
self._cw._(u'Download schema as OWL'))) |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
173 |
self.wview('schemagraph') |
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
|
174 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
175 |
class SchemaETypeTab(StartupView): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
176 |
__regid__ = 'schema-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
|
177 |
|
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
|
178 |
def call(self): |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
179 |
self.wview('table', self._cw.execute( |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
180 |
'Any X ORDERBY N WHERE X is CWEType, X name N, X final FALSE')) |
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
|
181 |
|
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
|
182 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
183 |
class SchemaRTypeTab(StartupView): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
184 |
__regid__ = 'schema-relation-types' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
185 |
|
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
186 |
def call(self): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
187 |
self.wview('table', self._cw.execute( |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
188 |
'Any X ORDERBY N WHERE X is CWRType, X name N, X final FALSE')) |
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
|
189 |
|
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
190 |
# CWEType ###################################################################### |
0 | 191 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
192 |
# register msgid generated in entity relations tables |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
193 |
_('i18ncard_1'), _('i18ncard_?'), _('i18ncard_+'), _('i18ncard_*') |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
194 |
|
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
195 |
class CWETypePrimaryView(tabs.TabbedPrimaryView): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
196 |
__select__ = is_instance('CWEType') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
197 |
tabs = [_('cwetype-description'), _('cwetype-box'), _('cwetype-workflow'), |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
198 |
_('cwetype-views'), _('cwetype-permissions')] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
199 |
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
|
200 |
|
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
201 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
202 |
class CWETypeDescriptionTab(tabs.PrimaryTab): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
203 |
__regid__ = 'cwetype-description' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
204 |
__select__ = tabs.PrimaryTab.__select__ & is_instance('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
|
205 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
206 |
def render_entity_attributes(self, entity): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
207 |
super(CWETypeDescriptionTab, self).render_entity_attributes(entity) |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
208 |
_ = self._cw._ |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
209 |
# inheritance |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
210 |
if entity.specializes: |
8213
076c80543fcd
[schema view] properly display inheritance (closes #870073).
Damien Garaud <damien.garaud@logilab.fr>
parents:
7845
diff
changeset
|
211 |
self.w(u'<div><strong>%s</strong>' % _('Parent class:')) |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
212 |
self.wview('csv', entity.related('specializes', 'subject')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
213 |
self.w(u'</div>') |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
214 |
if entity.reverse_specializes: |
8213
076c80543fcd
[schema view] properly display inheritance (closes #870073).
Damien Garaud <damien.garaud@logilab.fr>
parents:
7845
diff
changeset
|
215 |
self.w(u'<div><strong>%s</strong>' % _('Sub-classes:')) |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
216 |
self.wview('csv', entity.related('specializes', 'object')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
217 |
self.w(u'</div>') |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
218 |
# entity schema image |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
219 |
self.wview('schemagraph', etype=entity.name) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
220 |
# entity schema attributes |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
221 |
self.w(u'<h2>%s</h2>' % _('CWAttribute_plural')) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
222 |
rset = self._cw.execute( |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
223 |
'Any A,ON,D,C,A,DE,A, IDX,FTI,I18N,R,O,RN,S ORDERBY AA ' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
224 |
'WHERE A is CWAttribute, A from_entity S, S eid %(x)s, ' |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
225 |
'A ordernum AA, A defaultval D, A description DE, A cardinality C, ' |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
226 |
'A fulltextindexed FTI, A internationalizable I18N, A indexed IDX, ' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
227 |
'A relation_type R, R name RN, A to_entity O, O name ON', |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
228 |
{'x': entity.eid}) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
229 |
self.wview('table', rset, 'null', |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
230 |
cellvids={0: 'rdef-name-cell', |
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
231 |
2: 'etype-attr-defaultval-cell', |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
232 |
3: 'etype-attr-cardinality-cell', |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
233 |
4: 'rdef-constraints-cell', |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
234 |
6: 'rdef-options-cell'}, |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
235 |
headers=(_(u'name'), _(u'type'), |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
236 |
_(u'default value'), _(u'required'), |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
237 |
_(u'constraints'), _(u'description'), _('options'))) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
238 |
# entity schema relations |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
239 |
self.w(u'<h2>%s</h2>' % _('CWRelation_plural')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
240 |
cellvids = {0: 'rdef-name-cell', |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
241 |
2: 'etype-rel-cardinality-cell', |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
242 |
3: 'rdef-constraints-cell', |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
243 |
4: 'rdef-options-cell'} |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
244 |
headers= [_(u'name'), _(u'object type'), _(u'cardinality'), |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
245 |
_(u'constraints'), _(u'options')] |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
246 |
rset = self._cw.execute( |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
247 |
'Any A,TT,"i18ncard_"+SUBSTRING(C,1,1),A,A, K,TTN,R,RN ORDERBY RN ' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
248 |
'WHERE A is CWRelation, A from_entity S, S eid %(x)s, ' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
249 |
'A composite K, A cardinality C, ' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
250 |
'A relation_type R, R name RN, A to_entity TT, TT name TTN', |
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
|
251 |
{'x': entity.eid}) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
252 |
if rset: |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
253 |
self.w(u'<h5>%s %s</h5>' % (entity.name, _('is subject of:'))) |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
254 |
self.wview('table', rset, cellvids=cellvids, headers=headers) |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
255 |
rset = self._cw.execute( |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
256 |
'Any A,TT,"i18ncard_"+SUBSTRING(C,1,1),A,A, K,TTN,R,RN ORDERBY RN ' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
257 |
'WHERE A is CWRelation, A to_entity O, O eid %(x)s, ' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
258 |
'A composite K, A cardinality C, ' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
259 |
'A relation_type R, R name RN, A from_entity TT, TT name TTN', |
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
|
260 |
{'x': entity.eid}) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
261 |
if rset: |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
262 |
cellvids[0] = 'rdef-object-name-cell' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
263 |
headers[1] = _(u'subject type') |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
264 |
self.w(u'<h5>%s %s</h5>' % (entity.name, _('is object of:'))) |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
265 |
self.wview('table', rset, cellvids=cellvids, headers=headers) |
0 | 266 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
267 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
268 |
class CWETypeAttributeCardinalityCell(baseviews.FinalView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
269 |
__regid__ = 'etype-attr-cardinality-cell' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
270 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
271 |
def cell_call(self, row, col): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
272 |
if self.cw_rset.rows[row][col][0] == '1': |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
273 |
self.w(self._cw._(u'yes')) |
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
274 |
else: |
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
275 |
self.w(self._cw._(u'no')) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
276 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
277 |
|
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
278 |
class CWETypeAttributeDefaultValCell(baseviews.FinalView): |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
279 |
__regid__ = 'etype-attr-defaultval-cell' |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
280 |
|
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
281 |
def cell_call(self, row, col): |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
282 |
defaultval = self.cw_rset.rows[row][col] |
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
283 |
if defaultval is not None: |
10740
59e89db3a67d
[web] unicode → six.text_type
Julien Cristau <julien.cristau@logilab.fr>
parents:
10668
diff
changeset
|
284 |
self.w(text_type(self.cw_rset.rows[row][col].unzpickle())) |
9299
c5eed908117d
[schema] store default attribute values in a Bytes field, allowing python objects as default values
Aurélien Campeas <aurelien.campeas@logilab.fr>
parents:
8665
diff
changeset
|
285 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
286 |
class CWETypeRelationCardinalityCell(baseviews.FinalView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
287 |
__regid__ = 'etype-rel-cardinality-cell' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
288 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
289 |
def cell_call(self, row, col): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
290 |
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
|
291 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
292 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
293 |
class CWETypeBoxTab(EntityView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
294 |
__regid__ = 'cwetype-box' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
295 |
__select__ = is_instance('CWEType') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
296 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
297 |
def cell_call(self, row, col): |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
298 |
viewer = schemaviewer.SchemaViewer(self._cw) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
299 |
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
|
300 |
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
|
301 |
layout = viewer.visit_entityschema(eschema) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
302 |
self.w(uilib.ureport_as_html(layout)) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
303 |
self.w(u'<br class="clear"/>') |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
304 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
305 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
306 |
class CWETypePermTab(SecurityViewMixIn, EntityView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
307 |
__regid__ = 'cwetype-permissions' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
308 |
__select__ = is_instance('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
|
309 |
|
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
310 |
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
|
311 |
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
|
312 |
eschema = self._cw.vreg.schema.eschema(entity.name) |
6582
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6084
diff
changeset
|
313 |
self.w(u'<h4>%s</h4>' % self._cw._('This entity type permissions:')) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
314 |
self.permissions_table(eschema) |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
315 |
self.w(u'<div style="margin: 0px 1.5em">') |
6582
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6084
diff
changeset
|
316 |
self.w(u'<h4>%s</h4>' % self._cw._('Attributes permissions:')) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
317 |
for attr, etype in eschema.attribute_definitions(): |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
318 |
if attr not in META_RTYPES: |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
319 |
rdef = eschema.rdef(attr) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
320 |
attrtype = str(rdef.rtype) |
6582
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6084
diff
changeset
|
321 |
self.w(u'<h4 class="schema">%s (%s)</h4> ' |
8eb7883b4223
[pylint] fix a bug of pylint detected errors and i18n pb (calling builtins._ instead of req._)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6084
diff
changeset
|
322 |
% (attrtype, self._cw._(attrtype))) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
323 |
self.permissions_table(rdef) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
324 |
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
|
325 |
|
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
|
326 |
|
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
327 |
class CWETypeWorkflowTab(EntityView): |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
328 |
__regid__ = 'cwetype-workflow' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
329 |
__select__ = (is_instance('CWEType') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
330 |
& 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
|
331 |
|
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
332 |
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
|
333 |
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
|
334 |
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
|
335 |
wf = entity.default_workflow[0] |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
336 |
if len(entity.reverse_workflow_of) > 1: |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
337 |
self.w(u'<h1>%s (%s)</h1>' |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
338 |
% (wf.name, self._cw._('default_workflow'))) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
339 |
self.display_workflow(wf) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
340 |
defaultwfeid = wf.eid |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
341 |
else: |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
342 |
self.w(u'<div class="error">%s</div>' |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
343 |
% self._cw._('There is no default workflow')) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
344 |
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
|
345 |
for altwf in entity.reverse_workflow_of: |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
346 |
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
|
347 |
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
|
348 |
self.w(u'<h1>%s</h1>' % altwf.name) |
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
349 |
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
|
350 |
|
5224
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
351 |
def display_workflow(self, wf): |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
352 |
self.w(wf.view('wfgraph')) |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
353 |
self.w('<a href="%s">%s</a>' % ( |
34e669b6fd95
[mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4971
diff
changeset
|
354 |
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
|
355 |
|
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
356 |
|
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
357 |
class CWETypeViewsTab(EntityView): |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
358 |
"""possible views for this entity type""" |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
359 |
__regid__ = 'cwetype-views' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
360 |
__select__ = EntityView.__select__ & is_instance('CWEType') |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
361 |
|
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
362 |
def cell_call(self, row, col): |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
363 |
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
|
364 |
_ = self._cw._ |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
365 |
self.w('<div>%s</div>' % _('Non exhaustive list of views that may ' |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
366 |
'apply to entities of this type')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
367 |
views = [(view.content_type, view.__regid__, _(view.title)) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
368 |
for view in self.possible_views(entity.name)] |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
369 |
self.wview('pyvaltable', pyvalue=sorted(views), |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
370 |
headers=(_(u'content type'), _(u'view identifier'), |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
371 |
_(u'view title'))) |
5233
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
372 |
|
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
373 |
def possible_views(self, etype): |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
374 |
rset = self._cw.etype_rset(etype) |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
375 |
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
|
376 |
if v.category != 'startupview'] |
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
377 |
|
673b63953e7a
ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5232
diff
changeset
|
378 |
|
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
379 |
class CWETypeOneLineView(baseviews.OneLineView): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
380 |
__select__ = is_instance('CWEType') |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
381 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
382 |
def cell_call(self, row, col, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
383 |
entity = self.cw_rset.get_entity(row, col) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
384 |
if entity.final: |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
385 |
self.w(u'<em class="finalentity">') |
1398
5fe84a5f7035
rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents:
1263
diff
changeset
|
386 |
super(CWETypeOneLineView, self).cell_call(row, col, **kwargs) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
387 |
if entity.final: |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
388 |
self.w(u'</em>') |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
389 |
|
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
390 |
|
1998
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
391 |
# CWRType ###################################################################### |
12040c090aa4
[views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1977
diff
changeset
|
392 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
393 |
class CWRTypePrimaryView(tabs.TabbedPrimaryView): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
394 |
__select__ = is_instance('CWRType') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
395 |
tabs = [_('cwrtype-description'), _('cwrtype-permissions')] |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
396 |
default_tab = 'cwrtype-description' |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
397 |
|
0 | 398 |
|
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
399 |
class CWRTypeDescriptionTab(tabs.PrimaryTab): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
400 |
__regid__ = 'cwrtype-description' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
401 |
__select__ = is_instance('CWRType') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
402 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
403 |
def render_entity_attributes(self, entity): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
404 |
super(CWRTypeDescriptionTab, self).render_entity_attributes(entity) |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
405 |
_ = self._cw._ |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
406 |
if not entity.final: |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
407 |
self.wview('schemagraph', rtype=entity.name) |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
408 |
rset = self._cw.execute('Any R,C,R,R, RT WHERE ' |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
409 |
'R relation_type RT, RT eid %(x)s, ' |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
410 |
'R cardinality C', {'x': entity.eid}) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
411 |
self.wview('table', rset, 'null', |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
412 |
headers=(_(u'relation'), _(u'cardinality'), _(u'constraints'), |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
413 |
_(u'options')), |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
414 |
cellvids={2: 'rdef-constraints-cell', |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
415 |
3: 'rdef-options-cell'}) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
416 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
417 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
418 |
class CWRTypePermTab(SecurityViewMixIn, EntityView): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
419 |
__regid__ = 'cwrtype-permissions' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
420 |
__select__ = is_instance('CWRType') & authenticated_user() |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
421 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
422 |
def cell_call(self, row, col): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
423 |
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
|
424 |
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
|
425 |
self.grouped_permissions_table(rschema) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
426 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
427 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
428 |
# CWAttribute / CWRelation ##################################################### |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
429 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
430 |
class RDEFPrimaryView(tabs.TabbedPrimaryView): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
431 |
__select__ = is_instance('CWRelation', 'CWAttribute') |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
432 |
tabs = [_('rdef-description'), _('rdef-permissions')] |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
433 |
default_tab = 'rdef-description' |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
434 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
435 |
|
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
436 |
class RDEFDescriptionTab(tabs.PrimaryTab): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
437 |
__regid__ = 'rdef-description' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
438 |
__select__ = is_instance('CWRelation', 'CWAttribute') |
0 | 439 |
|
1556 | 440 |
def render_entity_attributes(self, entity): |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
441 |
super(RDEFDescriptionTab, self).render_entity_attributes(entity) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
442 |
rdef = entity.yams_schema() |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
443 |
if rdef.constraints: |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
444 |
self.w(u'<h4>%s</h4>' % self._cw._('constrained_by')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
445 |
self.w(entity.view('rdef-constraints-cell')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
446 |
|
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
447 |
|
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
448 |
class RDEFPermTab(SecurityViewMixIn, EntityView): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
449 |
__regid__ = 'rdef-permissions' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
450 |
__select__ = is_instance('CWRelation', 'CWAttribute') & authenticated_user() |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
451 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
452 |
def cell_call(self, row, col): |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
453 |
self.permissions_table(self.cw_rset.get_entity(row, col).yams_schema()) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
454 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
455 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
456 |
class RDEFNameView(tableview.CellView): |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
457 |
"""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
|
458 |
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
|
459 |
for instance) |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
460 |
""" |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
461 |
__regid__ = 'rdef-name-cell' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
462 |
__select__ = is_instance('CWRelation', 'CWAttribute') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
463 |
|
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
464 |
def cell_call(self, row, col): |
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
465 |
entity = self.cw_rset.get_entity(row, col) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
466 |
rtype = entity.relation_type[0].name |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
467 |
# XXX use context entity + pgettext |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
468 |
self.w(u'<a href="%s">%s</a> (%s)' % ( |
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
469 |
entity.absolute_url(), rtype, self._cw._(rtype))) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
470 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
471 |
class RDEFObjectNameView(tableview.CellView): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
472 |
"""same as RDEFNameView but when the context is the object entity |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
473 |
""" |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
474 |
__regid__ = 'rdef-object-name-cell' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
475 |
__select__ = is_instance('CWRelation', 'CWAttribute') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
476 |
|
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
477 |
def cell_call(self, row, col): |
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
478 |
entity = self.cw_rset.get_entity(row, col) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
479 |
rtype = entity.relation_type[0].name |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
480 |
# XXX use context entity + pgettext |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
481 |
self.w(u'<a href="%s">%s</a> (%s)' % ( |
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
482 |
entity.absolute_url(), rtype, self._cw.__(rtype + '_object'))) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
483 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
484 |
class RDEFConstraintsCell(EntityView): |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
485 |
__regid__ = 'rdef-constraints-cell' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
486 |
__select__ = is_instance('CWAttribute', 'CWRelation') |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
487 |
|
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
488 |
def cell_call(self, row, col): |
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
489 |
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
|
490 |
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
|
491 |
rdef = rschema.rdefs[(entity.stype.name, entity.otype.name)] |
10740
59e89db3a67d
[web] unicode → six.text_type
Julien Cristau <julien.cristau@logilab.fr>
parents:
10668
diff
changeset
|
492 |
constraints = [xml_escape(text_type(c)) for c in getattr(rdef, 'constraints')] |
5236
13296aa038a9
catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5235
diff
changeset
|
493 |
self.w(u'<br/>'.join(constraints)) |
5234
e2476d78b060
ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5233
diff
changeset
|
494 |
|
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
495 |
class CWAttributeOptionsCell(EntityView): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
496 |
__regid__ = 'rdef-options-cell' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
497 |
__select__ = is_instance('CWAttribute') |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
498 |
|
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
499 |
def cell_call(self, row, col): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
500 |
entity = self.cw_rset.get_entity(row, col) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
501 |
options = [] |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
502 |
if entity.indexed: |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
503 |
options.append(self._cw._('indexed')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
504 |
if entity.fulltextindexed: |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
505 |
options.append(self._cw._('fulltextindexed')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
506 |
if entity.internationalizable: |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
507 |
options.append(self._cw._('internationalizable')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
508 |
self.w(u','.join(options)) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
509 |
|
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
510 |
class CWRelationOptionsCell(EntityView): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
511 |
__regid__ = 'rdef-options-cell' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
512 |
__select__ = is_instance('CWRelation',) |
5239
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
513 |
|
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
514 |
def cell_call(self, row, col): |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
515 |
entity = self.cw_rset.get_entity(row, col) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
516 |
rtype = entity.rtype |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
517 |
options = [] |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
518 |
if rtype.symmetric: |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
519 |
options.append(self._cw._('symmetric')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
520 |
if rtype.inlined: |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
521 |
options.append(self._cw._('inlined')) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
522 |
if rtype.fulltext_container: |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
523 |
options.append('%s=%s' % (self._cw._('fulltext_container'), |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
524 |
self._cw._(rtype.fulltext_container))) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
525 |
if entity.composite: |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
526 |
options.append('%s=%s' % (self._cw._('composite'), |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
527 |
self._cw._(entity.composite))) |
471554b842d2
[schema view] the final touch. Things are getting nicely displayed, and code clean
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5236
diff
changeset
|
528 |
self.w(u','.join(options)) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
529 |
|
0 | 530 |
|
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
531 |
# schema images ############################################################### |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
532 |
|
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
|
533 |
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
|
534 |
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
|
535 |
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
|
536 |
super(RestrictedSchemaVisitorMixIn, self).__init__(*args, **kwargs) |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
537 |
|
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
|
538 |
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
|
539 |
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
|
540 |
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
|
541 |
|
3877
7ca53fc72a0a
reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3768
diff
changeset
|
542 |
def should_display_attr(self, eschema, rschema): |
4108
f9c51250480a
schema view fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4045
diff
changeset
|
543 |
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
|
544 |
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
|
545 |
|
0 | 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 FullSchemaVisitor(RestrictedSchemaVisitorMixIn, s2d.FullSchemaVisitor): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
548 |
pass |
0 | 549 |
|
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 |
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
|
551 |
s2d.OneHopESchemaVisitor): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
552 |
pass |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
553 |
|
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
|
554 |
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
|
555 |
s2d.OneHopRSchemaVisitor): |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
556 |
pass |
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
557 |
|
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
558 |
class CWSchemaDotPropsHandler(s2d.SchemaDotPropsHandler): |
7215
2da7f3ec4e6f
[schema diagram] proper url generation (closes #1621276)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6961
diff
changeset
|
559 |
def __init__(self, visitor, cw): |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
560 |
self.visitor = visitor |
7215
2da7f3ec4e6f
[schema diagram] proper url generation (closes #1621276)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6961
diff
changeset
|
561 |
self.cw = cw |
10668
4fb62d791073
[web/views] use next builtin instead of next method
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10666
diff
changeset
|
562 |
self._cycle = iter(cycle(('#ff7700', '#000000', '#ebbc69', '#888888'))) |
4fb62d791073
[web/views] use next builtin instead of next method
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10666
diff
changeset
|
563 |
self.nextcolor = lambda: next(self._cycle) |
4fb62d791073
[web/views] use next builtin instead of next method
Rémi Cardona <remi.cardona@logilab.fr>
parents:
10666
diff
changeset
|
564 |
|
5688
21658a3a386a
[schema view] improve it slightly by attributing the same color to rdef of the same relation type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5686
diff
changeset
|
565 |
self.colors = {} |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
566 |
|
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
567 |
def node_properties(self, eschema): |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
568 |
"""return DOT drawing options for an entity schema include href""" |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
569 |
label = ['{',eschema.type,'|'] |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
570 |
label.append(r'\l'.join('%s (%s)' % (rel.type, eschema.rdef(rel.type).object) |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
571 |
for rel in eschema.ordered_relations() |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
572 |
if rel.final and self.visitor.should_display_attr(eschema, rel))) |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
573 |
label.append(r'\l}') # trailing \l ensure alignement of the last one |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
574 |
return {'label' : ''.join(label), 'shape' : "record", |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
575 |
'fontname' : "Courier", 'style' : "filled", |
7215
2da7f3ec4e6f
[schema diagram] proper url generation (closes #1621276)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6961
diff
changeset
|
576 |
'href': self.cw.build_url('cwetype/%s' % eschema.type), |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
577 |
'fontsize': '10px' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
578 |
} |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
579 |
|
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
580 |
def edge_properties(self, rschema, subjnode, objnode): |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
581 |
"""return default DOT drawing options for a relation schema""" |
8213
076c80543fcd
[schema view] properly display inheritance (closes #870073).
Damien Garaud <damien.garaud@logilab.fr>
parents:
7845
diff
changeset
|
582 |
# Inheritance relation (i.e 'specializes'). |
076c80543fcd
[schema view] properly display inheritance (closes #870073).
Damien Garaud <damien.garaud@logilab.fr>
parents:
7845
diff
changeset
|
583 |
if rschema is None: |
076c80543fcd
[schema view] properly display inheritance (closes #870073).
Damien Garaud <damien.garaud@logilab.fr>
parents:
7845
diff
changeset
|
584 |
kwargs = {'label': 'Parent class', |
076c80543fcd
[schema view] properly display inheritance (closes #870073).
Damien Garaud <damien.garaud@logilab.fr>
parents:
7845
diff
changeset
|
585 |
'color' : 'grey', 'style' : 'filled', |
076c80543fcd
[schema view] properly display inheritance (closes #870073).
Damien Garaud <damien.garaud@logilab.fr>
parents:
7845
diff
changeset
|
586 |
'arrowhead': 'empty', |
076c80543fcd
[schema view] properly display inheritance (closes #870073).
Damien Garaud <damien.garaud@logilab.fr>
parents:
7845
diff
changeset
|
587 |
'fontsize': '10px'} |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
588 |
# symmetric rels are handled differently, let yams decide what's best |
8213
076c80543fcd
[schema view] properly display inheritance (closes #870073).
Damien Garaud <damien.garaud@logilab.fr>
parents:
7845
diff
changeset
|
589 |
elif rschema.symmetric: |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
590 |
kwargs = {'label': rschema.type, |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
591 |
'color': '#887788', 'style': 'dashed', |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
592 |
'dir': 'both', 'arrowhead': 'normal', 'arrowtail': 'normal', |
7215
2da7f3ec4e6f
[schema diagram] proper url generation (closes #1621276)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6961
diff
changeset
|
593 |
'fontsize': '10px', |
2da7f3ec4e6f
[schema diagram] proper url generation (closes #1621276)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6961
diff
changeset
|
594 |
'href': self.cw.build_url('cwrtype/%s' % rschema.type)} |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
595 |
else: |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
596 |
kwargs = {'label': rschema.type, |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
597 |
'color' : 'black', 'style' : 'filled', 'fontsize': '10px', |
7215
2da7f3ec4e6f
[schema diagram] proper url generation (closes #1621276)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6961
diff
changeset
|
598 |
'href': self.cw.build_url('cwrtype/%s' % rschema.type)} |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
599 |
rdef = rschema.rdef(subjnode, objnode) |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
600 |
composite = rdef.composite |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
601 |
if rdef.composite == 'subject': |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
602 |
kwargs['arrowhead'] = 'none' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
603 |
kwargs['arrowtail'] = 'diamond' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
604 |
elif rdef.composite == 'object': |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
605 |
kwargs['arrowhead'] = 'diamond' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
606 |
kwargs['arrowtail'] = 'none' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
607 |
else: |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
608 |
kwargs['arrowhead'] = 'open' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
609 |
kwargs['arrowtail'] = 'none' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
610 |
# UML like cardinalities notation, omitting 1..1 |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
611 |
if rdef.cardinality[1] != '1': |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
612 |
kwargs['taillabel'] = s2d.CARD_MAP[rdef.cardinality[1]] |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
613 |
if rdef.cardinality[0] != '1': |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
614 |
kwargs['headlabel'] = s2d.CARD_MAP[rdef.cardinality[0]] |
5688
21658a3a386a
[schema view] improve it slightly by attributing the same color to rdef of the same relation type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5686
diff
changeset
|
615 |
try: |
21658a3a386a
[schema view] improve it slightly by attributing the same color to rdef of the same relation type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5686
diff
changeset
|
616 |
kwargs['color'] = self.colors[rschema] |
5689
18d4e78b9369
[schema view] only catch key errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5688
diff
changeset
|
617 |
except KeyError: |
5688
21658a3a386a
[schema view] improve it slightly by attributing the same color to rdef of the same relation type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5686
diff
changeset
|
618 |
kwargs['color'] = self.nextcolor() |
21658a3a386a
[schema view] improve it slightly by attributing the same color to rdef of the same relation type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5686
diff
changeset
|
619 |
self.colors[rschema] = kwargs['color'] |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
620 |
kwargs['fontcolor'] = kwargs['color'] |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
621 |
# dot label decoration is just awful (1 line underlining the label |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
622 |
# + 1 line going to the closest edge spline point) |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
623 |
kwargs['decorate'] = 'false' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
624 |
#kwargs['labelfloat'] = 'true' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
625 |
return kwargs |
1091
b5e253c0dd13
a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents:
1012
diff
changeset
|
626 |
|
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
|
627 |
|
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
628 |
class SchemaGraphView(StartupView): |
3377
dd9d292b6a6d
use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
629 |
__regid__ = 'schemagraph' |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
630 |
|
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
631 |
def call(self, etype=None, rtype=None, alt=''): |
9383
7b3fa5a7a5a3
[views/dot] use an inlined svg for schema and workflow graphs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
632 |
if 'MSIE 8' in self._cw.useragent(): |
7b3fa5a7a5a3
[views/dot] use an inlined svg for schema and workflow graphs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
633 |
return |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
634 |
schema = self._cw.vreg.schema |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
635 |
if etype: |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
636 |
assert rtype is None |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
637 |
visitor = OneHopESchemaVisitor(self._cw, schema.eschema(etype), |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
638 |
skiptypes=skip_types(self._cw)) |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
639 |
alt = self._cw._('graphical representation of the %(etype)s ' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
640 |
'entity type from %(appid)s data model') |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
641 |
elif rtype: |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
642 |
visitor = OneHopRSchemaVisitor(self._cw, schema.rschema(rtype), |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
643 |
skiptypes=skip_types(self._cw)) |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
644 |
alt = self._cw._('graphical representation of the %(rtype)s ' |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
645 |
'relation type from %(appid)s data model') |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
646 |
else: |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
647 |
visitor = FullSchemaVisitor(self._cw, schema, |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
648 |
skiptypes=skip_types(self._cw)) |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
649 |
alt = self._cw._('graphical representation of %(appid)s data model') |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
650 |
alt %= {'rtype': rtype, 'etype': etype, |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
651 |
'appid': self._cw.vreg.config.appid} |
7215
2da7f3ec4e6f
[schema diagram] proper url generation (closes #1621276)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6961
diff
changeset
|
652 |
prophdlr = CWSchemaDotPropsHandler(visitor, self._cw) |
5686
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
653 |
generator = GraphGenerator(DotBackend('schema', 'BT', |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
654 |
ratio='compress',size=None, |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
655 |
renderer='dot', |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
656 |
additionnal_param={ |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
657 |
'overlap':'false', |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
658 |
'splines':'true', |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
659 |
'sep':'0.2', |
bbb89ba88b69
[schema diagram] ticket #191599, make schema image look better
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents:
5556
diff
changeset
|
660 |
})) |
9383
7b3fa5a7a5a3
[views/dot] use an inlined svg for schema and workflow graphs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
661 |
# svg image file |
7b3fa5a7a5a3
[views/dot] use an inlined svg for schema and workflow graphs
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
9299
diff
changeset
|
662 |
fd, tmpfile = tempfile.mkstemp('.svg') |
10970
894c14f08380
[web/views] unlink svg temp file after we're done
Julien Cristau <julien.cristau@logilab.fr>
parents:
10405
diff
changeset
|
663 |
try: |
894c14f08380
[web/views] unlink svg temp file after we're done
Julien Cristau <julien.cristau@logilab.fr>
parents:
10405
diff
changeset
|
664 |
os.close(fd) |
894c14f08380
[web/views] unlink svg temp file after we're done
Julien Cristau <julien.cristau@logilab.fr>
parents:
10405
diff
changeset
|
665 |
generator.generate(visitor, prophdlr, tmpfile) |
894c14f08380
[web/views] unlink svg temp file after we're done
Julien Cristau <julien.cristau@logilab.fr>
parents:
10405
diff
changeset
|
666 |
with codecs.open(tmpfile, 'rb', encoding='utf-8') as svgfile: |
894c14f08380
[web/views] unlink svg temp file after we're done
Julien Cristau <julien.cristau@logilab.fr>
parents:
10405
diff
changeset
|
667 |
self.w(svgfile.read()) |
894c14f08380
[web/views] unlink svg temp file after we're done
Julien Cristau <julien.cristau@logilab.fr>
parents:
10405
diff
changeset
|
668 |
finally: |
894c14f08380
[web/views] unlink svg temp file after we're done
Julien Cristau <julien.cristau@logilab.fr>
parents:
10405
diff
changeset
|
669 |
os.unlink(tmpfile) |
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
|
670 |
|
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
671 |
# breadcrumbs ################################################################## |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
672 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
673 |
class CWRelationIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
674 |
__select__ = is_instance('CWRelation') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
675 |
def parent_entity(self): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
676 |
return self.entity.rtype |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
677 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
678 |
class CWAttributeIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
679 |
__select__ = is_instance('CWAttribute') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
680 |
def parent_entity(self): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
681 |
return self.entity.stype |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1398
diff
changeset
|
682 |
|
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
683 |
class CWConstraintIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
684 |
__select__ = is_instance('CWConstraint') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
685 |
def parent_entity(self): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
686 |
if self.entity.reverse_constrained_by: |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
687 |
return self.entity.reverse_constrained_by[0] |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
688 |
|
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
689 |
class RQLExpressionIBreadCrumbsAdapter(ibreadcrumbs.IBreadCrumbsAdapter): |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
690 |
__select__ = is_instance('RQLExpression') |
5556
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
691 |
def parent_entity(self): |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
692 |
return self.entity.expression_of |
9ab2b4c74baf
[entity] introduce a new 'adapters' registry
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5527
diff
changeset
|
693 |
|
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
|
694 |
|
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
|
695 |
# 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
|
696 |
|
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
|
697 |
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
|
698 |
__regid__ = 'cwfinal-facet' |
5877
0c7b7b76a84f
[selectors] provide a new, optimized, is_instance selector that should at some point replace implements (along with the adaptable selector)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5823
diff
changeset
|
699 |
__select__ = facet.AttributeFacet.__select__ & is_instance('CWEType', 'CWRType') |
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
|
700 |
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
|
701 |
|
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6854
diff
changeset
|
702 |
|
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
|
703 |
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
|
704 |
__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
|
705 |
__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
|
706 |
|
7810
21683b1975e3
[i18n] tweaks
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7797
diff
changeset
|
707 |
title = _('data model 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
|
708 |
order = 30 |
6961
686c59dfc401
[manage view] cleanup manage view and user menu
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6854
diff
changeset
|
709 |
category = 'manage' |
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
|
710 |
|
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
|
711 |
def url(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3377
diff
changeset
|
712 |
return self._cw.build_url(self.__regid__) |