web/uicfg.py
author sylvain.thenault@logilab.fr
Mon, 11 May 2009 11:55:10 +0200
branchtls-sprint
changeset 1723 30c3a713ab61
parent 1721 694f6a50e138
child 1739 78b0819162a8
permissions -rw-r--r--
View.dispatch -> View.render
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
     1
"""schema driven ui configuration.
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
     2
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
     3
set of properties configuring edition, actions box, ... rendering using tags
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
     4
on schema relations. Those properties are defined here so we don't get module
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
reloading problems.
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
     6
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
     7
:organization: Logilab
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
     8
:copyright: 2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
     9
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    10
"""
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    11
__docformat__ = "restructuredtext en"
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1498
diff changeset
    12
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1498
diff changeset
    13
from cubicweb.rtags import RelationTags, RelationTagsSet
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    14
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    15
# primary view configuration ##################################################
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    16
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    17
# how to display a relation in primary view.
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    18
# values a dict with the following keys:
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    19
#
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    20
# 'where', whose value may be one of:
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    21
#  * 'attributes', display in the attributes section
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    22
#  * 'relations', display in the relations section (below attributes)
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    23
#  * 'sideboxes', display in the side boxes (beside attributes)
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    24
# if this key is missing, the relation won't be displayed at all.
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    25
#
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    26
# 'vid' is an optional view identifier
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    27
#
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    28
# 'label' is an optional label
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    29
#
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    30
# 'limit' is a boolean telling if the results should be limited according to
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    31
#  the configuration
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    32
class RDisplayRelationTags(RelationTags):
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    33
    def __init__(self):
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    34
        super(RDisplayRelationTags, self).__init__()
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    35
        self._counter = 0
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    36
1723
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1721
diff changeset
    37
    def tag_relation(self, stype, rtype, otype, tag, tagged=None):
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1721
diff changeset
    38
        super(RDisplayRelationTags, self).tag_relation(stype, rtype, otype, tag,
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1721
diff changeset
    39
                                                       tagged)
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1721
diff changeset
    40
        if tag:
30c3a713ab61 View.dispatch -> View.render
sylvain.thenault@logilab.fr
parents: 1721
diff changeset
    41
            tag['order'] = self.get_timestamp()
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    42
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    43
    def get_timestamp(self):
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    44
        self._counter += 1
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    45
        return self._counter
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    46
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    47
rdisplay = RDisplayRelationTags()
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    48
for rtype in ('eid', 'creation_date', 'modification_date',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    49
              'is', 'is_instance_of', 'identity',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    50
              'owned_by', 'created_by',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    51
              'in_state', 'wf_info_for', 'require_permission',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    52
              'from_entity', 'to_entity',
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    53
              'see_also'):
1721
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    54
    rdisplay.tag_relation('!*', rtype, '*', {})
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    55
    rdisplay.tag_relation('*', rtype, '!*', {})
1554
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    56
3a3263df6cdd new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents: 1533
diff changeset
    57
1631
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
    58
# index view configuration ####################################################
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
    59
# entity type category in the index/manage page. May be one of
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
    60
# * 'application'
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
    61
# * 'system'
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
    62
# * 'schema'
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
    63
# * 'subobject' (not displayed by default)
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
    64
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
    65
etypecat = {'EmailAddress': 'subobject'}
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
    66
8370be19afd7 configurable entity types tables
sylvain.thenault@logilab.fr
parents: 1604
diff changeset
    67
1498
2c6eec0b46b9 fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents: 1468
diff changeset
    68
# autoform.AutomaticEntityForm configuration ##################################
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    69
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    70
# relations'category (eg primary/secondary/generic/metadata/generated)
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    71
rcategories = RelationTags()
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    72
# use primary and not generated for eid since it has to be an hidden
1721
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    73
rcategories.tag_attribute('*', 'eid', 'primary')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    74
rcategories.tag_attribute('*', 'description', 'secondary')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    75
rcategories.tag_attribute('*', 'creation_date', 'metadata')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    76
rcategories.tag_attribute('*', 'modification_date', 'metadata')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    77
rcategories.tag_attribute('*', 'has_text', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    78
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    79
rcategories.tag_relation('!*', 'in_state', '*', 'primary')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    80
rcategories.tag_relation('!*', 'owned_by', '*', 'metadata')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    81
rcategories.tag_relation('!*', 'created_by', '*', 'metadata')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    82
rcategories.tag_relation('!*', 'is', '*', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    83
rcategories.tag_relation('*', 'is', '!*', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    84
rcategories.tag_relation('!*', 'is_instance_of', '*', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    85
rcategories.tag_relation('*', 'is_instance_of', '!*', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    86
rcategories.tag_relation('!*', 'identity', '*', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    87
rcategories.tag_relation('*', 'identity', '!*', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    88
rcategories.tag_relation('!*', 'require_permission', '*', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    89
rcategories.tag_relation('!*', 'wf_info_for', '*', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    90
rcategories.tag_relation('*', 'wf_info_for', '!*', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    91
rcategories.tag_relation('!*', 'for_user', '*', 'generated')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
    92
rcategories.tag_relation('*', 'for_user', '!*', 'generated')
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    93
1313
9cff1eee0208 put class, not class name into rwidgets. New rfields rtags to specify a field for a relation
sylvain.thenault@logilab.fr
parents: 1285
diff changeset
    94
# relations'field class
9cff1eee0208 put class, not class name into rwidgets. New rfields rtags to specify a field for a relation
sylvain.thenault@logilab.fr
parents: 1285
diff changeset
    95
rfields = RelationTags()
9cff1eee0208 put class, not class name into rwidgets. New rfields rtags to specify a field for a relation
sylvain.thenault@logilab.fr
parents: 1285
diff changeset
    96
9cff1eee0208 put class, not class name into rwidgets. New rfields rtags to specify a field for a relation
sylvain.thenault@logilab.fr
parents: 1285
diff changeset
    97
# relations'widget class
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    98
rwidgets = RelationTags()
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
    99
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   100
# inlined view flag for non final relations: when True for an entry, the
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   101
# entity(ies) at the other end of the relation will be editable from the
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   102
# form of the edited entity
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   103
rinlined = RelationTags()
1721
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   104
rinlined.tag_relation('!*', 'use_email', '*', True)
1604
fd943737d630 delete-trailing-whitespaces
sylvain.thenault@logilab.fr
parents: 1554
diff changeset
   105
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   106
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   107
# set of tags of the form <action>_on_new on relations. <action> is a
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   108
# schema action (add/update/delete/read), and when such a tag is found
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   109
# permissions checking is by-passed and supposed to be ok
1533
bcd4bfff658b update rtags api
sylvain.thenault@logilab.fr
parents: 1498
diff changeset
   110
rpermissions_overrides = RelationTagsSet()
1285
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   111
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   112
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   113
# boxes.EditBox configuration #################################################
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   114
d5ce82d65c2b for a correct handling of rtags, they should not ever be reloaded and they should be initialized once registration is finished
sylvain.thenault@logilab.fr
parents:
diff changeset
   115
# 'link' / 'create' relation tags, used to control the "add entity" submenu
1468
500ca81a344a oos, set rmode for wf_info_for / object
sylvain.thenault@logilab.fr
parents: 1313
diff changeset
   116
rmode = RelationTags()
1721
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   117
rmode.tag_relation('!*', 'is', '*', 'link')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   118
rmode.tag_relation('*', 'is', '!*', 'link')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   119
rmode.tag_relation('!*', 'is_instance_of', '*', 'link')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   120
rmode.tag_relation('*', 'is_instance_of', '!*', 'link')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   121
rmode.tag_relation('!*', 'identity', '*', 'link')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   122
rmode.tag_relation('*', 'identity', '!*', 'link')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   123
rmode.tag_relation('!*', 'owned_by', '*', 'link')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   124
rmode.tag_relation('!*', 'created_by', '*', 'link')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   125
rmode.tag_relation('!*', 'require_permission', '*', 'link')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   126
rmode.tag_relation('!*', 'wf_info_for', '*', 'link')
694f6a50e138 final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents: 1631
diff changeset
   127
rmode.tag_relation('*', 'wf_info_for', '!*', 'link')