web/views/schema.py
author Alexandre Fayolle <alexandre.fayolle@logilab.fr>
Thu, 03 Jun 2010 09:41:41 +0200
branchstable
changeset 5649 a07dee204187
parent 5525 c4eee9921e19
child 5527 01a7228ab5a0
child 5798 74d9a062965c
permissions -rw-r--r--
fix unit tests by not using the new create_eid implementation with sqlite Actually, fix a couple of issues with a previous attempt: * do not use double underscores as method patching will fail with these * old method must always be used with sqlite regardless of the no_sqlite_wrap attribute
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
     1
# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
8167de96c523 proper licensing information (LGPL-2.1). Hope I get it right this time.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 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/>.
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    18
"""Specific views for schema related entities
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    19
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    20
"""
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    21
__docformat__ = "restructuredtext en"
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    22
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    23
from itertools import cycle
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
    24
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
    25
from logilab.common.ureports import Section, Table
2312
af4d8f75c5db use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2277
diff changeset
    26
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
    27
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
    28
from yams.buildobjs import DEFAULT_ATTRPERMS
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    29
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
    30
from cubicweb.selectors import (implements, yes, match_user_groups,
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    31
                                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
    32
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
    33
                             WORKFLOW_TYPES, INTERNAL_TYPES)
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
    34
from cubicweb.view import EntityView, StartupView
4023
eae23c40627a drop common subpackage
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3890
diff changeset
    35
from cubicweb import tags, uilib
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
    36
from cubicweb.web import action, facet, uicfg, schemaviewer
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
    37
from cubicweb.web.views import TmpFileViewMixin
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    38
from cubicweb.web.views import primary, baseviews, tabs, tableview, iprogress
1151
b20677336ee6 turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    39
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
    40
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
    41
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
    42
               | INTERNAL_TYPES)
4434
101344a6ff9b Improve the schema command with filtering option.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 4252
diff changeset
    43
SKIP_TYPES.update(set(('CWUser', 'CWGroup')))
1151
b20677336ee6 turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
    44
2181
94ca417b9b07 backport stable branch, make schema-security consistent with other schema views changes, uniformize skipmeta/withmeta
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2126 2172
diff changeset
    45
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>
parents: 2126 2172
diff changeset
    46
    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
    47
        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
    48
    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
    49
3768
8c85a2f7f5ad nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
    50
_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
    51
_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
    52
3768
8c85a2f7f5ad nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
    53
for _action in ('read', 'add', 'update', 'delete'):
8c85a2f7f5ad nicer relation|entity schema view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3689
diff changeset
    54
    _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
    55
    _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
    56
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
    57
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
    58
    _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
    59
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
    60
_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
    61
_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
    62
_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
    63
_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
    64
_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
    65
_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
    66
_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
    67
_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
    68
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(('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
    70
_pvs.tag_attribute(('CWRType', 'final'), 'hidden')
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    71
_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
    72
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
    73
_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
    74
_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
    75
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
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    77
class SecurityViewMixIn(object):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    78
    """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
    79
    relation or relation definition schema
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    80
    """
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    81
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    82
    def permissions_table(self, erschema, permissions=None):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    83
        self._cw.add_css('cubicweb.acl.css')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    84
        w = self.w
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    85
        _ = self._cw._
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    86
        w(u'<table class="schemaInfo">')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    87
        w(u'<tr><th>%s</th><th>%s</th><th>%s</th></tr>' % (
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    88
            _("permission"), _('granted to groups'), _('rql expressions')))
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    89
        for action in erschema.ACTIONS:
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    90
            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
    91
            if permissions is None:
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    92
                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
    93
                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
    94
            else:
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
    95
                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
    96
                rqlexprs = permissions[action][1]
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
    97
            # 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
    98
            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
    99
                group, self._cw.build_url('cwgroup/%s' % group), label)
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   100
                      for group, label 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
   101
            w(u'<br/>'.join(groups))
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   102
            w(u'</td><td>')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   103
            w(u'<br/>'.join(rqlexprs))
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   104
            w(u'</td></tr>\n')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   105
        w(u'</table>')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   106
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   107
    def grouped_permissions_table(self, rschema):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   108
        # group relation definitions with identical permissions
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   109
        perms = {}
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   110
        for rdef in rschema.rdefs.itervalues():
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   111
            rdef_perms = []
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   112
            for action in ('read', 'add', 'delete'):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   113
                groups = sorted(rdef.get_groups(action))
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   114
                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
   115
                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
   116
            rdef_perms = tuple(rdef_perms)
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   117
            if rdef_perms in perms:
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   118
                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
   119
            else:
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   120
                perms[rdef_perms] = [(rdef.subject, rdef.object)]
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   121
        # 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
   122
        # definition
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   123
        w = self.w
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   124
        w(u'<div style="margin: 0px 1.5em">')
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   125
        tmpl = u'<strong>%s</strong> %s <strong>%s</strong>'
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   126
        for perm, rdefs in perms.iteritems():
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   127
            w(u'<div>%s</div>' % u', '.join(
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   128
                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
   129
            # 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
   130
            # ACTIONS
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   131
            self.permissions_table(rdef, dict(perm))
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   132
        w(u'</div>')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   133
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   134
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   135
# 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
   136
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
   137
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
   138
    """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
   139
    __regid__ = 'schema'
2476
1294a6bdf3bf application -> instance where it makes sense
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2436
diff changeset
   140
    title = _('instance schema')
5525
c4eee9921e19 [views] tab schema image renamed to schema diagram
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   141
    tabs = [_('schema-diagram'), _('schema-entity-types'),
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
   142
            _('schema-relation-types'), _('schema-security')]
5525
c4eee9921e19 [views] tab schema image renamed to schema diagram
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   143
    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
   144
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
    def call(self):
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   146
        self.w(u'<h1>%s</h1>' % _('Schema of the data model'))
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   147
        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
   148
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
   149
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   150
class SchemaImageTab(StartupView):
5525
c4eee9921e19 [views] tab schema image renamed to schema diagram
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 5426
diff changeset
   151
    __regid__ = 'schema-diagram'
1151
b20677336ee6 turn old __rtags__ the new way
sylvain.thenault@logilab.fr
parents: 1132
diff changeset
   152
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   153
    def call(self):
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   154
        self.w(_(u'<div>This schema of the data model <em>excludes</em> the '
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   155
                 u'meta-data, but you can also display a <a href="%s">complete '
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   156
                 u'schema with meta-data</a>.</div>')
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   157
               % 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
   158
        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
   159
               (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
   160
                self._cw._(u'Download schema as OWL')))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   161
        self.w(u'<img src="%s" alt="%s"/>\n' % (
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   162
            xml_escape(self._cw.build_url('view', vid='schemagraph', skipmeta=1)),
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   163
            self._cw._("graphical representation of the instance'schema")))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   164
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
   165
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
   166
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
   167
    __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
   168
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
   169
    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
   170
        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
   171
            '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
   172
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   173
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
   174
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
   175
    __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
   176
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
   177
    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
   178
        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
   179
            '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
   180
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
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   182
class SchemaPermissionsTab(SecurityViewMixIn, StartupView):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   183
    __regid__ = 'schema-security'
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   184
    __select__ = StartupView.__select__ & match_user_groups('managers')
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   185
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   186
    def call(self, display_relations=True):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   187
        skiptypes = skip_types(self._cw)
4045
f4a52abb6f4f cw 3.6 api update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 4023
diff changeset
   188
        schema = self._cw.vreg.schema
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   189
        # compute entities
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   190
        entities = sorted(eschema for eschema in schema.entities()
3689
deb13e88e037 follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3555
diff changeset
   191
                          if not (eschema.final or eschema in skiptypes))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   192
        # compute relations
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   193
        if display_relations:
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   194
            relations = sorted(rschema for rschema in schema.relations()
3689
deb13e88e037 follow yams 0.25 api changes to improve performance
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3555
diff changeset
   195
                               if not (rschema.final
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   196
                                       or rschema in skiptypes
2617
89c62b855f2e [R schema hooks] rename META_RELATIONS_TYPES into META_RTYPES, use it and other schema consts to avoid errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2476
diff changeset
   197
                                       or rschema in META_RTYPES))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   198
        else:
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   199
            relations = []
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   200
        # index
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   201
        _ = self._cw._
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   202
        url = xml_escape(self._cw.build_url('schema'))
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   203
        self.w(u'<div id="schema_security">')
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   204
        self.w(u'<h2 class="schema">%s</h2>' % _('Index'))
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   205
        self.w(u'<h4 id="entities">%s</h4>' % _('Entity types'))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   206
        ents = []
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   207
        for eschema in sorted(entities):
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   208
            ents.append(u'<a class="grey" href="%s#%s">%s</a>' % (
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   209
                url,  eschema.type, eschema.type))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   210
        self.w(u', '.join(ents))
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   211
        self.w(u'<h4 id="relations">%s</h4>' % _('Relation types'))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   212
        rels = []
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   213
        for rschema in sorted(relations):
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   214
            rels.append(u'<a class="grey" href="%s#%s">%s</a>' %  (
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   215
                url , rschema.type, rschema.type))
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   216
        self.w(u', '.join(rels))
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   217
        # permissions tables
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   218
        self.display_entities(entities)
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   219
        if relations:
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   220
            self.display_relations(relations)
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   221
        self.w(u'</div>')
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   222
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   223
    def has_non_default_perms(self, rdef):
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   224
        """return true if the given *attribute* relation definition has custom
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   225
        permission
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   226
        """
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   227
        for action in rdef.ACTIONS:
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   228
            def_rqlexprs = []
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   229
            def_groups = []
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   230
            for perm in DEFAULT_ATTRPERMS[action]:
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   231
                if not isinstance(perm, basestring):
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   232
                    def_rqlexprs.append(perm.expression)
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   233
                else:
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   234
                    def_groups.append(perm)
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   235
            rqlexprs = [rql.expression for rql in rdef.get_rqlexprs(action)]
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   236
            groups = rdef.get_groups(action)
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   237
            if groups != frozenset(def_groups) or \
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   238
                frozenset(rqlexprs) != frozenset(def_rqlexprs):
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   239
                return True
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   240
        return False
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   241
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   242
    def display_entities(self, entities):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   243
        _ = self._cw._
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   244
        url = xml_escape(self._cw.build_url('schema'))
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   245
        self.w(u'<h2 id="entities" class="schema">%s</h2>' % _('Permissions for entity types'))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   246
        for eschema in entities:
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   247
            self.w(u'<h3 id="%s" class="schema"><a href="%s">%s (%s)</a> ' % (
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   248
                eschema.type, self._cw.build_url('cwetype/%s' % eschema.type),
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   249
                eschema.type, _(eschema.type)))
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   250
            self.w(u'<a href="%s#schema_security"><img src="%s" alt="%s"/></a>' % (
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   251
                url,  self._cw.external_resource('UP_ICON'), _('up')))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   252
            self.w(u'</h3>')
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   253
            self.w(u'<div style="margin: 0px 1.5em">')
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   254
            self.permissions_table(eschema)
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   255
            # display entity attributes only if they have some permissions modified
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   256
            modified_attrs = []
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   257
            for attr, etype in  eschema.attribute_definitions():
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   258
                rdef = eschema.rdef(attr)
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   259
                if attr not in META_RTYPES and self.has_non_default_perms(rdef):
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   260
                    modified_attrs.append(rdef)
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   261
            if modified_attrs:
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   262
                self.w(u'<h4>%s</h4>' % _('Attributes with non default permissions:'))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   263
                self.w(u'</div>')
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   264
                self.w(u'<div style="margin: 0px 6em">')
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   265
                for rdef in modified_attrs:
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   266
                    attrtype = str(rdef.rtype)
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   267
                    self.w(u'<h4 class="schema">%s (%s)</h4> ' % (attrtype, _(attrtype)))
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   268
                    self.permissions_table(rdef)
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   269
            self.w(u'</div>')
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   270
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   271
    def display_relations(self, relations):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   272
        _ = self._cw._
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   273
        url = xml_escape(self._cw.build_url('schema'))
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   274
        self.w(u'<h2 id="relations" class="schema">%s</h2>' % _('Permissions for relations'))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   275
        for rschema in relations:
5232
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   276
            self.w(u'<h3 id="%s" class="schema"><a href="%s">%s (%s)</a> ' % (
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   277
                rschema.type, self._cw.build_url('cwrtype/%s' % rschema.type),
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   278
                rschema.type, _(rschema.type)))
78c1a531f7b3 ticket #787032, schema view improvement
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5224
diff changeset
   279
            self.w(u'<a href="%s#schema_security"><img src="%s" alt="%s"/></a>' % (
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   280
                url,  self._cw.external_resource('UP_ICON'), _('up')))
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   281
            self.w(u'</h3>')
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   282
            self.grouped_permissions_table(rschema)
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   283
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
   284
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   285
# CWEType ######################################################################
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   286
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   287
# register msgid generated in entity relations tables
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   288
_('i18ncard_1'), _('i18ncard_?'), _('i18ncard_+'), _('i18ncard_*')
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   289
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   290
class CWETypePrimaryView(tabs.TabbedPrimaryView):
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   291
    __select__ = implements('CWEType')
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   292
    tabs = [_('cwetype-description'), _('cwetype-box'), _('cwetype-workflow'),
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   293
            _('cwetype-views'), _('cwetype-permissions')]
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   294
    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
   295
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   296
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   297
class CWETypeDescriptionTab(tabs.PrimaryTab):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   298
    __regid__ = 'cwetype-description'
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   299
    __select__ = tabs.PrimaryTab.__select__ & implements('CWEType')
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   300
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
   301
    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
   302
        super(CWETypeDescriptionTab, self).render_entity_attributes(entity)
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   303
        _ = 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
   304
        # 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
   305
        if entity.specializes:
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
   306
            self.w(u'<div>%s' % _('Parent classes:'))
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
   307
            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
   308
            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
   309
        if entity.reverse_specializes:
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
   310
            self.w(u'<div>%s' % _('Sub-classes:'))
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
   311
            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
   312
            self.w(u'</div>')
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   313
        # entity schema image
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   314
        self.w(u'<img src="%s" alt="%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
   315
            xml_escape(entity.absolute_url(vid='schemagraph')),
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   316
            xml_escape(_('graphical schema for %s') % entity.name)))
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   317
        # 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
   318
        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
   319
        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
   320
            '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
   321
            '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
   322
            '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
   323
            '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
   324
            '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
   325
            {'x': entity.eid})
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   326
        self.wview('table', rset, 'null',
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   327
                   cellvids={0: 'rdef-name-cell',
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   328
                             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
   329
                             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
   330
                             6: 'rdef-options-cell'},
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   331
                   headers=(_(u'name'), _(u'type'),
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   332
                            _(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
   333
                            _(u'constraints'), _(u'description'), _('options')))
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   334
        # 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
   335
        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
   336
        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
   337
                    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
   338
                    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
   339
                    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
   340
        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
   341
                  _(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
   342
        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
   343
            '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
   344
            '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
   345
            '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
   346
            '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
   347
            {'x': entity.eid})
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   348
        if rset:
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   349
            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
   350
            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
   351
        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
   352
            '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
   353
            '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
   354
            '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
   355
            '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
   356
            {'x': entity.eid})
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   357
        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
   358
            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
   359
            headers[1] = _(u'subject type')
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   360
            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
   361
            self.wview('table', rset, cellvids=cellvids, headers=headers)
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   362
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   363
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   364
class CWETypeAttributeCardinalityCell(baseviews.FinalView):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   365
    __regid__ = 'etype-attr-cardinality-cell'
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   366
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   367
    def cell_call(self, row, col):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   368
        if self.cw_rset.rows[row][col][0] == '1':
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   369
            self.w(self._cw._(u'yes'))
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   370
        else:
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   371
            self.w(self._cw._(u'no'))
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   372
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   373
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   374
class CWETypeRelationCardinalityCell(baseviews.FinalView):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   375
    __regid__ = 'etype-rel-cardinality-cell'
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   376
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   377
    def cell_call(self, row, col):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   378
        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
   379
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   380
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   381
class CWETypeBoxTab(EntityView):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   382
    __regid__ = 'cwetype-box'
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   383
    __select__ = implements('CWEType')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   384
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   385
    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
   386
        viewer = schemaviewer.SchemaViewer(self._cw)
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   387
        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
   388
        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
   389
        layout = viewer.visit_entityschema(eschema)
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   390
        self.w(uilib.ureport_as_html(layout))
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   391
        self.w(u'<br class="clear"/>')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   392
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   393
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   394
class CWETypePermTab(SecurityViewMixIn, EntityView):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   395
    __regid__ = 'cwetype-permissions'
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   396
    __select__ = implements('CWEType') & authenticated_user()
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   397
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   398
    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
   399
        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
   400
        eschema = self._cw.vreg.schema.eschema(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
   401
        self.w(u'<h4>%s</h4>' % _('This entity type permissions:').capitalize())
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   402
        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
   403
        self.w(u'<div style="margin: 0px 1.5em">')
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
        self.w(u'<h4>%s</h4>' % _('Attributes permissions:').capitalize())
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   405
        for attr, etype in  eschema.attribute_definitions():
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   406
            if attr not in META_RTYPES:
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   407
                rdef = eschema.rdef(attr)
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   408
                attrtype = str(rdef.rtype)
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   409
                self.w(u'<h4 class="schema">%s (%s)</h4> ' % (attrtype, _(attrtype)))
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   410
                self.permissions_table(rdef)
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   411
        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
   412
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
   413
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   414
class CWETypeWorkflowTab(EntityView):
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   415
    __regid__ = 'cwetype-workflow'
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   416
    __select__ = (implements('CWEType')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   417
                  & 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
   418
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   419
    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
   420
        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
   421
        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
   422
            wf = entity.default_workflow[0]
5224
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   423
            if len(entity.reverse_workflow_of) > 1:
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   424
                self.w(u'<h1>%s (%s)</h1>'
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   425
                       % (wf.name, self._cw._('default_workflow')))
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   426
            self.display_workflow(wf)
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   427
            defaultwfeid = wf.eid
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   428
        else:
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   429
            self.w(u'<div class="error">%s</div>'
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   430
                   % self._cw._('There is no default workflow'))
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   431
            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
   432
        for altwf in entity.reverse_workflow_of:
5224
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   433
            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
   434
                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
   435
            self.w(u'<h1>%s</h1>' % altwf.name)
5224
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   436
            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
   437
5224
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   438
    def display_workflow(self, wf):
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   439
        self.w(wf.view('wfgraph'))
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   440
        self.w('<a href="%s">%s</a>' % (
34e669b6fd95 [mq]: worklfow view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4971
diff changeset
   441
            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
   442
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   443
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   444
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
   445
    """possible views for this entity type"""
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   446
    __regid__ = 'cwetype-views'
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   447
    __select__ = EntityView.__select__ & implements('CWEType')
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   448
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   449
    def cell_call(self, row, col):
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   450
        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
   451
        _ = 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
   452
        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
   453
                                   '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
   454
        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
   455
                 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
   456
        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
   457
                   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
   458
                            _(u'view title')))
5233
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   459
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   460
    def possible_views(self, etype):
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   461
        rset = self._cw.etype_rset(etype)
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   462
        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
   463
                if v.category != 'startupview']
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   464
673b63953e7a ticket #787103, entity schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5232
diff changeset
   465
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   466
class CWETypeOneLineView(baseviews.OneLineView):
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   467
    __select__ = implements('CWEType')
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   468
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   469
    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
   470
        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
   471
        if entity.final:
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   472
            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
   473
        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
   474
        if entity.final:
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   475
            self.w(u'</em>')
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   476
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   477
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   478
# CWRType ######################################################################
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   479
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   480
class CWRTypePrimaryView(tabs.TabbedPrimaryView):
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   481
    __select__ = implements('CWRType')
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   482
    tabs = [_('cwrtype-description'), _('cwrtype-permissions')]
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   483
    default_tab = 'cwrtype-description'
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   484
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   485
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   486
class CWRTypeDescriptionTab(tabs.PrimaryTab):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   487
    __regid__ = 'cwrtype-description'
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   488
    __select__ = implements('CWRType')
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   489
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
   490
    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
   491
        super(CWRTypeDescriptionTab, self).render_entity_attributes(entity)
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   492
        _ = 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
   493
        if not entity.final:
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   494
            msg = _('graphical schema for %s') % entity.name
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   495
            self.w(tags.img(src=entity.absolute_url(vid='schemagraph'),
1556
b64a0fe1fc86 cleanup
sylvain.thenault@logilab.fr
parents: 1554
diff changeset
   496
                            alt=msg))
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
   497
        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
   498
                                '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
   499
                                'R cardinality C', {'x': entity.eid})
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   500
        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
   501
                   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
   502
                            _(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
   503
                   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
   504
                             3: 'rdef-options-cell'})
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   505
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   506
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   507
class CWRTypePermTab(SecurityViewMixIn, EntityView):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   508
    __regid__ = 'cwrtype-permissions'
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   509
    __select__ = implements('CWRType') & authenticated_user()
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   510
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   511
    def cell_call(self, row, col):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   512
        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
   513
        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
   514
        self.grouped_permissions_table(rschema)
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   515
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   516
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   517
# CWAttribute / CWRelation #####################################################
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   518
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
   519
class RDEFPrimaryView(tabs.TabbedPrimaryView):
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   520
    __select__ = implements('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
   521
    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
   522
    default_tab = 'rdef-description'
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   523
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
   524
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
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
   526
    __regid__ = 'rdef-description'
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   527
    __select__ = implements('CWRelation', 'CWAttribute')
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   528
1556
b64a0fe1fc86 cleanup
sylvain.thenault@logilab.fr
parents: 1554
diff changeset
   529
    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
   530
        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
   531
        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
   532
        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
   533
            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
   534
            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
   535
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
   536
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
   537
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
   538
    __regid__ = 'rdef-permissions'
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   539
    __select__ = implements('CWRelation', 'CWAttribute') & authenticated_user()
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   540
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   541
    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
   542
        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
   543
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   544
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
   545
class RDEFNameView(tableview.CellView):
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   546
    """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
   547
    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
   548
    for instance)
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   549
    """
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   550
    __regid__ = 'rdef-name-cell'
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   551
    __select__ = implements('CWRelation', 'CWAttribute')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   552
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   553
    def cell_call(self, row, col):
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   554
        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
   555
        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
   556
        # XXX use context entity + pgettext
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   557
        self.w(u'<a href="%s">%s</a> (%s)' % (
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   558
            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
   559
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
   560
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
   561
    """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
   562
    """
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   563
    __regid__ = 'rdef-object-name-cell'
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   564
    __select__ = implements('CWRelation', 'CWAttribute')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   565
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   566
    def cell_call(self, row, col):
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   567
        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
   568
        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
   569
        # XXX use context entity + pgettext
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   570
        self.w(u'<a href="%s">%s</a> (%s)' % (
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   571
            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
   572
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
   573
class RDEFConstraintsCell(EntityView):
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   574
    __regid__ = 'rdef-constraints-cell'
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   575
    __select__ = implements('CWAttribute', 'CWRelation')
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   576
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   577
    def cell_call(self, row, col):
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   578
        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
   579
        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
   580
        rdef = rschema.rdefs[(entity.stype.name, entity.otype.name)]
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   581
        constraints = [xml_escape(str(c)) for c in getattr(rdef, 'constraints')]
5236
13296aa038a9 catalogs update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5235
diff changeset
   582
        self.w(u'<br/>'.join(constraints))
5234
e2476d78b060 ticket #787103, relation schema view enhancements
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 5233
diff changeset
   583
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
   584
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
   585
    __regid__ = '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
   586
    __select__ = implements('CWAttribute')
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
   587
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
   588
    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
   589
        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
   590
        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
   591
        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
   592
            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
   593
        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
   594
            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
   595
        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
   596
            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
   597
        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
   598
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
   599
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
   600
    __regid__ = '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
   601
    __select__ = implements('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
   602
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
   603
    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
   604
        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
   605
        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
   606
        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
   607
        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
   608
            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
   609
        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
   610
            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
   611
        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
   612
            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
   613
                                      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
   614
        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
   615
            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
   616
                                      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
   617
        self.w(u','.join(options))
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   618
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   619
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   620
# schema images ###############################################################
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   621
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
   622
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
   623
    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
   624
        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
   625
        super(RestrictedSchemaVisitorMixIn, self).__init__(*args, **kwargs)
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   626
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
   627
    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
   628
        return (super(RestrictedSchemaVisitorMixIn, self).should_display_schema(rschema)
3890
d7a270f50f54 backport stable branch (one more time painfully)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3777 3877
diff changeset
   629
                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
   630
3877
7ca53fc72a0a reldefsecurity branch :
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3768
diff changeset
   631
    def should_display_attr(self, eschema, rschema):
4108
f9c51250480a schema view fix
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 4045
diff changeset
   632
        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>
parents: 3777 3877
diff changeset
   633
                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
   634
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   635
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
   636
class FullSchemaVisitor(RestrictedSchemaVisitorMixIn, s2d.FullSchemaVisitor):
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   637
    pass
0
b97547f5f1fa Showtime !
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
diff changeset
   638
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
   639
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
   640
                           s2d.OneHopESchemaVisitor):
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   641
    pass
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   642
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
   643
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
   644
                           s2d.OneHopRSchemaVisitor):
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   645
    pass
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   646
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   647
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   648
class SchemaImageView(TmpFileViewMixin, StartupView):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   649
    __regid__ = 'schemagraph'
2126
a25859917ccc stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1998
diff changeset
   650
    content_type = 'image/png'
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   651
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   652
    def _generate(self, tmpfile):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   653
        """display global schema information"""
4045
f4a52abb6f4f cw 3.6 api update
Sandrine Ribeau <sandrine.ribeau@logilab.fr>
parents: 4023
diff changeset
   654
        visitor = FullSchemaVisitor(self._cw, self._cw.vreg.schema,
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   655
                                    skiptypes=skip_types(self._cw))
2126
a25859917ccc stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1998
diff changeset
   656
        s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   657
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
   658
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   659
class CWETypeSchemaImageView(TmpFileViewMixin, EntityView):
3377
dd9d292b6a6d use __regid__ instead of id on appobject classes
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 3293
diff changeset
   660
    __regid__ = 'schemagraph'
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
   661
    __select__ = implements('CWEType')
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   662
    content_type = 'image/png'
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   663
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   664
    def _generate(self, tmpfile):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   665
        """display schema information for an entity"""
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   666
        entity = self.cw_rset.get_entity(self.cw_row, self.cw_col)
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   667
        eschema = self._cw.vreg.schema.eschema(entity.name)
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   668
        visitor = OneHopESchemaVisitor(self._cw, eschema,
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   669
                                       skiptypes=skip_types(self._cw))
2126
a25859917ccc stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1998
diff changeset
   670
        s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   671
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
   672
1398
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   673
class CWRTypeSchemaImageView(CWETypeSchemaImageView):
5fe84a5f7035 rename internal entity types to have CW prefix instead of E
sylvain.thenault@logilab.fr
parents: 1263
diff changeset
   674
    __select__ = implements('CWRType')
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1398
diff changeset
   675
1091
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   676
    def _generate(self, tmpfile):
b5e253c0dd13 a bit of reorganisation inside web/views:
sylvain.thenault@logilab.fr
parents: 1012
diff changeset
   677
        """display schema information for an entity"""
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   678
        entity = self.cw_rset.get_entity(self.cw_row, self.cw_col)
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   679
        rschema = self._cw.vreg.schema.rschema(entity.name)
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   680
        visitor = OneHopRSchemaVisitor(self._cw, rschema)
2126
a25859917ccc stop using meta attribute from yams schema. Use instead sets defining meta relations and another defining schema types. Refactor various schema view based on this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 1998
diff changeset
   681
        s2d.schema2dot(outputfile=tmpfile, visitor=visitor)
1998
12040c090aa4 [views] change schema views: remove view eschema and use tabs for cwetype
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1977
diff changeset
   682
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
   683
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
   684
# 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
   685
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
   686
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
   687
    __regid__ = 'cwfinal-facet'
2436
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   688
    __select__ = facet.AttributeFacet.__select__ & implements('CWEType', 'CWRType')
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   689
    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
   690
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
   691
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
   692
    __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
   693
    __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
   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
    title = _("site schema")
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   696
    category = 'siteactions'
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   697
    order = 30
44b2eea35efa move all schema related views where they belong (eg not startup), fix schema graph views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents: 2387
diff changeset
   698
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
   699
    def url(self):
3451
6b46d73823f5 [api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents: 3377
diff changeset
   700
        return self._cw.build_url(self.__regid__)