author | Adrien Di Mascio <Adrien.DiMascio@logilab.fr> |
Thu, 24 Sep 2009 00:24:21 +0200 | |
changeset 3460 | e4843535db25 |
parent 3369 | 7b88d12b4ee2 |
child 3476 | 6e927b729ae1 |
permissions | -rw-r--r-- |
1739 | 1 |
"""This module regroups a set of structures that may be used to configure |
2 |
various places of the generated web interface. |
|
3 |
||
4 |
Primary view configuration |
|
5 |
`````````````````````````` |
|
6 |
:primaryview_section: |
|
7 |
where to display a relation in primary view. Value may be one of: |
|
8 |
* 'attributes', display in the attributes section |
|
9 |
* 'relations', display in the relations section (below attributes) |
|
10 |
* 'sideboxes', display in the side boxes (beside attributes) |
|
11 |
* 'hidden', don't display |
|
12 |
||
13 |
:primaryview_display_ctrl: |
|
14 |
||
15 |
how to display a relation in primary view. Values are dict with some of the |
|
16 |
following keys: |
|
17 |
||
18 |
:vid: |
|
19 |
identifier of a view to use to display the result set. Defaults depends on |
|
20 |
the section: |
|
21 |
* 'attributes' section: 'reledit' view |
|
22 |
* 'relations' section: 'autolimited' view |
|
23 |
* 'sideboxes' section: 'sidebox' view |
|
24 |
||
25 |
:label: |
|
26 |
label for the relations section or side box |
|
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
|
27 |
|
1739 | 28 |
:limit: |
29 |
boolean telling if the results should be limited according to the |
|
30 |
configuration |
|
31 |
||
32 |
:filter: |
|
33 |
callback taking the related result set as argument and returning it |
|
34 |
filtered |
|
35 |
||
36 |
:order: |
|
37 |
int used to control order within a section. When not specified, |
|
38 |
automatically set according to order in which tags are added. |
|
39 |
||
40 |
Notice those values are only considered if the relation is in a displayed |
|
41 |
section (controlled by :attr:`primaryview_section`) |
|
42 |
||
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
|
43 |
|
1739 | 44 |
Index view configuration |
45 |
```````````````````````` |
|
46 |
:indexview_etype_section: |
|
47 |
entity type category in the index/manage page. May be one of |
|
48 |
* 'application' |
|
49 |
* 'system' |
|
50 |
* 'schema' |
|
51 |
* 'subobject' (not displayed by default) |
|
52 |
||
53 |
||
54 |
Actions box configuration |
|
55 |
````````````````````````` |
|
56 |
:actionbox_appearsin_addmenu: |
|
57 |
simple boolean relation tags used to control the "add entity" submenu. |
|
58 |
Relations whose rtag is True will appears, other won't. |
|
59 |
||
60 |
Automatic form configuration |
|
61 |
```````````````````````````` |
|
62 |
||
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1944
diff
changeset
|
63 |
:organization: Logilab |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1944
diff
changeset
|
64 |
:copyright: 2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1944
diff
changeset
|
65 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1944
diff
changeset
|
66 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
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
|
67 |
""" |
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
|
68 |
__docformat__ = "restructuredtext en" |
1533 | 69 |
|
3057
f4ba5a251ab7
generic rtag cleaing method
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
70 |
from cubicweb import neg_role |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
71 |
from cubicweb.rtags import (RelationTags, RelationTagsBool, |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
72 |
RelationTagsSet, RelationTagsDict, register_rtag) |
1739 | 73 |
from cubicweb.web import formwidgets |
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
|
74 |
|
1745
7e7f04d19a98
a bunch of NameError (!) // needs review //
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1742
diff
changeset
|
75 |
|
1746
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
76 |
def card_from_role(card, role): |
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
77 |
if role == 'subject': |
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
78 |
return card[0] |
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
79 |
assert role in ('object', 'sobject'), repr(role) |
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
80 |
return card[1] |
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
81 |
|
1944
a1b1d4f8482c
similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1878
diff
changeset
|
82 |
# primary view configuration ################################################## |
a1b1d4f8482c
similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1878
diff
changeset
|
83 |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
84 |
def init_primaryview_section(rtag, sschema, rschema, oschema, role): |
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
85 |
if rtag.get(sschema, rschema, oschema, role) is None: |
1746
67a9b86fd479
oops, keep python 2.4 compat
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1745
diff
changeset
|
86 |
card = card_from_role(rschema.rproperty(sschema, oschema, 'cardinality'), role) |
1944
a1b1d4f8482c
similar method already exists
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1878
diff
changeset
|
87 |
composed = rschema.rproperty(sschema, oschema, 'composite') == neg_role(role) |
1739 | 88 |
if rschema.is_final(): |
2671
ee5538bdf0ea
[uicfg] fix metadata detection in primaryview_section
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2652
diff
changeset
|
89 |
if rschema.meta or sschema.is_metadata(rschema) \ |
ee5538bdf0ea
[uicfg] fix metadata detection in primaryview_section
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2652
diff
changeset
|
90 |
or oschema.type in ('Password', 'Bytes'): |
1739 | 91 |
section = 'hidden' |
92 |
else: |
|
93 |
section = 'attributes' |
|
94 |
elif card in '1+': |
|
95 |
section = 'attributes' |
|
96 |
elif composed: |
|
97 |
section = 'relations' |
|
98 |
else: |
|
99 |
section = 'sideboxes' |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
100 |
rtag.tag_relation((sschema, rschema, oschema, role), section) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
101 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
102 |
primaryview_section = RelationTags('primaryview_section', |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
103 |
init_primaryview_section, |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
104 |
frozenset(('attributes', 'relations', |
1739 | 105 |
'sideboxes', 'hidden'))) |
106 |
||
107 |
||
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
108 |
class DisplayCtrlRelationTags(RelationTagsDict): |
1739 | 109 |
def __init__(self, *args, **kwargs): |
110 |
super(DisplayCtrlRelationTags, self).__init__(*args, **kwargs) |
|
111 |
self._counter = 0 |
|
112 |
||
113 |
def tag_relation(self, key, tag): |
|
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
114 |
tag = super(DisplayCtrlRelationTags, self).tag_relation(key, tag) |
1739 | 115 |
self._counter += 1 |
116 |
tag.setdefault('order', self._counter) |
|
117 |
||
2191
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
118 |
def tag_subject_of(self, key, tag): |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
119 |
subj, rtype, obj = key |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
120 |
if obj != '*': |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
121 |
self.warning('using explict target type in display_ctrl.tag_subject_of() ' |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
122 |
'has no effect, use (%s, %s, "*") instead of (%s, %s, %s)', |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
123 |
subj, rtype, subj, rtype, obj) |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
124 |
super(DisplayCtrlRelationTags, self).tag_subject_of((subj, rtype, '*'), tag) |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
125 |
|
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
126 |
def tag_object_of(self, key, tag): |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
127 |
subj, rtype, obj = key |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
128 |
if subj != '*': |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
129 |
self.warning('using explict subject type in display_ctrl.tag_object_of() ' |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
130 |
'has no effect, use ("*", %s, %s) instead of (%s, %s, %s)', |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
131 |
rtype, obj, subj, rtype, obj) |
1f0fde12e35b
[rtags] override tag_xxx_of() methods in DisplayCtrlRelationTags to make sure a wildcard is used
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1977
diff
changeset
|
132 |
super(DisplayCtrlRelationTags, self).tag_object_of(('*', rtype, obj), tag) |
1739 | 133 |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
134 |
def init_primaryview_display_ctrl(rtag, sschema, rschema, oschema, role): |
1739 | 135 |
if role == 'subject': |
136 |
oschema = '*' |
|
137 |
label = rschema.type |
|
138 |
else: |
|
139 |
sschema = '*' |
|
140 |
label = '%s_%s' % (rschema, role) |
|
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
141 |
rtag.setdefault((sschema, rschema, oschema, role), 'label', label) |
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
142 |
rtag.setdefault((sschema, rschema, oschema, role), 'order', rtag._counter) |
1739 | 143 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
144 |
primaryview_display_ctrl = DisplayCtrlRelationTags('primaryview_display_ctrl', |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
145 |
init_primaryview_display_ctrl) |
1554
3a3263df6cdd
new primary view using uicfg.rdisplay (major api cleanup)
sylvain.thenault@logilab.fr
parents:
1533
diff
changeset
|
146 |
|
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
147 |
# index view configuration #################################################### |
1739 | 148 |
# entity type section in the index/manage page. May be one of |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
149 |
# * 'application' |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
150 |
# * 'system' |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
151 |
# * 'schema' |
2951
d0b77dd27740
[wf] BaseTransition is a virtual type
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
152 |
# * 'hidden' |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
153 |
# * 'subobject' (not displayed by default) |
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
154 |
|
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
155 |
class InitializableDict(dict): |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
156 |
def __init__(self, *args, **kwargs): |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
157 |
super(InitializableDict, self).__init__(*args, **kwargs) |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
158 |
register_rtag(self) |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
159 |
|
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
160 |
def init(self, schema, check=True): |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
161 |
for eschema in schema.entities(): |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
162 |
if eschema.schema_entity(): |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
163 |
self.setdefault(eschema, 'schema') |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
164 |
elif eschema.is_subobject(strict=True): |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
165 |
self.setdefault(eschema, 'subobject') |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
166 |
else: |
2806
9d7173656a1a
proper rewrite
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2803
diff
changeset
|
167 |
self.setdefault(eschema, 'application') |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
168 |
|
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
169 |
indexview_etype_section = InitializableDict(EmailAddress='subobject', |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
170 |
CWUser='system', |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
171 |
CWGroup='system', |
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
172 |
CWPermission='system', |
3293 | 173 |
CWCache='system', |
2968
0e3460341023
somewhat painful backport of 3.5 branch, should mostly be ok
Sylvain Thénault <sylvain.thenault@logilab.fr>
diff
changeset
|
174 |
BaseTransition='hidden', |
2803
870fa705dfde
remove usage of vreg_initialization_complete by using an 'initializable dict' (eg call init after complete registration
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2705
diff
changeset
|
175 |
) |
1631
8370be19afd7
configurable entity types tables
sylvain.thenault@logilab.fr
parents:
1604
diff
changeset
|
176 |
|
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1468
diff
changeset
|
177 |
# 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
|
178 |
|
1739 | 179 |
# relations'section (eg primary/secondary/generic/metadata/generated) |
180 |
||
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
181 |
def init_autoform_section(rtag, sschema, rschema, oschema, role): |
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
182 |
if rtag.get(sschema, rschema, oschema, role) is None: |
3351
2ea19d969a2d
[uicfg] automatically set generated for the opposite of inlined relation as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3316
diff
changeset
|
183 |
if autoform_is_inlined.get(sschema, rschema, oschema, role) or \ |
2ea19d969a2d
[uicfg] automatically set generated for the opposite of inlined relation as well
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3316
diff
changeset
|
184 |
autoform_is_inlined.get(sschema, rschema, oschema, neg_role(role)): |
3127
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
185 |
section = 'generated' |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
186 |
elif sschema.is_metadata(rschema): |
2505
5d7d4af9eadf
fix some default autoform_section
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2465
diff
changeset
|
187 |
section = 'metadata' |
3127
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
188 |
else: |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
189 |
if role == 'subject': |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
190 |
card = rschema.rproperty(sschema, oschema, 'cardinality')[0] |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
191 |
composed = rschema.rproperty(sschema, oschema, 'composite') == 'object' |
1739 | 192 |
else: |
3127
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
193 |
card = rschema.rproperty(sschema, oschema, 'cardinality')[1] |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
194 |
composed = rschema.rproperty(sschema, oschema, 'composite') == 'subject' |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
195 |
if card in '1+': |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
196 |
if not rschema.is_final() and composed: |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
197 |
# XXX why? probably because we want it unlined, though this |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
198 |
# is not the case by default |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
199 |
section = 'generated' |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
200 |
else: |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
201 |
section = 'primary' |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
202 |
elif rschema.is_final(): |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
203 |
section = 'secondary' |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
204 |
else: |
920079cb4e5b
should have been done in stable
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3057
diff
changeset
|
205 |
section = 'generic' |
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
206 |
rtag.tag_relation((sschema, rschema, oschema, role), section) |
1721
694f6a50e138
final rtags api (eventually :$)
sylvain.thenault@logilab.fr
parents:
1631
diff
changeset
|
207 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
208 |
autoform_section = RelationTags('autoform_section', init_autoform_section, |
1739 | 209 |
set(('primary', 'secondary', 'generic', |
210 |
'metadata', '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
|
211 |
|
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
|
212 |
# relations'field class |
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
213 |
autoform_field = RelationTags('autoform_field') |
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
|
214 |
|
1754
c9c7618a90de
autoform_widget superseeded by autoform_field_kwargs (api change addiction :-/)
sylvain.thenault@logilab.fr
parents:
1747
diff
changeset
|
215 |
# relations'field explicit kwargs (given to field's __init__) |
2369
5a2b8ed266ca
new RelationTagsDict class, use it in uicfg where necessary
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2191
diff
changeset
|
216 |
autoform_field_kwargs = RelationTagsDict() |
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
|
217 |
|
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
|
218 |
# 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
|
219 |
# 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
|
220 |
# form of the edited entity |
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
221 |
autoform_is_inlined = RelationTagsBool('autoform_is_inlined') |
1604 | 222 |
|
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
|
223 |
|
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
|
224 |
# 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
|
225 |
# 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
|
226 |
# permissions checking is by-passed and supposed to be ok |
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
227 |
autoform_permissions_overrides = RelationTagsSet('autoform_permissions_overrides') |
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
|
228 |
|
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
|
229 |
# 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
|
230 |
|
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
|
231 |
# 'link' / 'create' relation tags, used to control the "add entity" submenu |
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
232 |
def init_actionbox_appearsin_addmenu(rtag, sschema, rschema, oschema, role): |
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
233 |
if rtag.get(sschema, rschema, oschema, role) is None: |
1739 | 234 |
card = rschema.rproperty(sschema, oschema, 'cardinality')[role == 'object'] |
235 |
if not card in '?1' and \ |
|
236 |
rschema.rproperty(sschema, oschema, 'composite') == role: |
|
1742
25a765e756c4
fix self on initfunc
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1739
diff
changeset
|
237 |
rtag.tag_relation((sschema, rschema, oschema, role), True) |
1739 | 238 |
|
1849
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
239 |
actionbox_appearsin_addmenu = RelationTagsBool('actionbox_appearsin_addmenu', |
1901fa97f521
give a name to rtags instance to ease debugging
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1819
diff
changeset
|
240 |
init_actionbox_appearsin_addmenu) |