author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Thu, 21 Jan 2010 10:48:00 +0100 | |
changeset 4306 | 01e5efc0d823 |
parent 4295 | b9590e68c543 |
child 4360 | 5fdb9da1fab0 |
permissions | -rw-r--r-- |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
1 |
"""The automatic entity form. |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
2 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
3 |
:organization: Logilab |
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3874
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
5 |
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1969
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
7 |
""" |
4160 | 8 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
9 |
__docformat__ = "restructuredtext en" |
1702 | 10 |
_ = unicode |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
11 |
|
4277
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
12 |
from logilab.common.decorators import cached, iclassmethod |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
13 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
14 |
from cubicweb import typed_eid |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
15 |
from cubicweb.web import stdmsgs, uicfg |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
16 |
from cubicweb.web import form, formwidgets as fwdgs |
4277
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
17 |
from cubicweb.web.views import forms, editforms, editviews |
1528
864ae7c15ef5
other fixlets
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1498
diff
changeset
|
18 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
19 |
_afs = uicfg.autoform_section |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
20 |
|
2005
e8032965f37a
turn every form class into appobject. They should not be instantiated manually anymore.
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
1982
diff
changeset
|
21 |
class AutomaticEntityForm(forms.EntityFieldsForm): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
22 |
"""base automatic form to edit any entity. |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
23 |
|
1560
7dd2a81b8bc8
[basecontrollers] add edit_relation next to edit_field, misc notes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1540
diff
changeset
|
24 |
Designed to be fully generated from schema but highly configurable through: |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
25 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
26 |
* uicfg (autoform_* relation tags) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
27 |
* various standard form parameters |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
28 |
* overriding |
2780
ad1dfc3855b0
B web/tests back to green
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2652
diff
changeset
|
29 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
30 |
You can also easily customise it by adding/removing fields in |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
31 |
AutomaticEntityForm instances or by inheriting from it. |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
32 |
""" |
3408
c92170fca813
[api] use __regid__ instead of deprecated id
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
33 |
__regid__ = 'edition' |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
34 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
35 |
cwtarget = 'eformframe' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
36 |
cssclass = 'entityForm' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
37 |
copy_nav_params = True |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
38 |
form_buttons = [fwdgs.SubmitButton(), |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
39 |
fwdgs.Button(stdmsgs.BUTTON_APPLY, cwaction='apply'), |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
40 |
fwdgs.Button(stdmsgs.BUTTON_CANCEL, cwaction='cancel')] |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
41 |
# for attributes selection when searching in uicfg.autoform_section |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
42 |
formtype = 'main' |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
43 |
# set this to a list of [(relation, role)] if you want to explictily tell |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
44 |
# which relations should be edited |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
45 |
display_fields = None |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
46 |
|
4277
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
47 |
def _generic_relations_field(self): |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
48 |
try: |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
49 |
srels_by_cat = self.srelations_by_category('generic', 'add', strict=True) |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
50 |
warn('[3.6] %s: srelations_by_category is deprecated, use uicfg or ' |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
51 |
'override editable_relations instead' % classid(form), |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
52 |
DeprecationWarning) |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
53 |
except AttributeError: |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
54 |
srels_by_cat = self.editable_relations() |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
55 |
if not srels_by_cat: |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
56 |
raise form.FieldNotFound('_cw_generic_field') |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
57 |
return editviews.GenericRelationsField(self.editable_relations()) |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
58 |
|
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
59 |
@iclassmethod |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
60 |
def field_by_name(cls_or_self, name, role=None, eschema=None): |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
61 |
"""return field with the given name and role. If field is not explicitly |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
62 |
defined for the form but `eclass` is specified, guess_field will be |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
63 |
called. |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
64 |
""" |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
65 |
try: |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
66 |
return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role, eschema) |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
67 |
except form.FieldNotFound: |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
68 |
if name == '_cw_generic_field' and not isinstance(cls_or_self, type): |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
69 |
return cls_or_self._generic_relations_field() |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
70 |
raise |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
71 |
|
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
72 |
# base automatic entity form methods ####################################### |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
73 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
74 |
def __init__(self, *args, **kwargs): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
75 |
super(AutomaticEntityForm, self).__init__(*args, **kwargs) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
76 |
entity = self.edited_entity |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
77 |
if entity.has_eid(): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
78 |
entity.complete() |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
79 |
for rtype, role in self.editable_attributes(): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
80 |
try: |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
81 |
self.field_by_name(str(rtype), role) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
82 |
continue # explicitly specified |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
83 |
except form.FieldNotFound: |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
84 |
# has to be guessed |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
85 |
try: |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
86 |
field = self.field_by_name(str(rtype), role, |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
87 |
eschema=entity.e_schema) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
88 |
self.fields.append(field) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
89 |
except form.FieldNotFound: |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
90 |
# meta attribute such as <attr>_format |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
91 |
continue |
4295
b9590e68c543
allow control of generic relations field display through display_fields
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4277
diff
changeset
|
92 |
if self.formtype == 'main' and entity.has_eid() and ( |
b9590e68c543
allow control of generic relations field display through display_fields
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4277
diff
changeset
|
93 |
self.display_fields is None or |
b9590e68c543
allow control of generic relations field display through display_fields
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4277
diff
changeset
|
94 |
'_cw_generic_field' in self.display_fields): |
4277
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
95 |
try: |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
96 |
self.fields.append(self.field_by_name('_cw_generic_field')) |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
97 |
except form.FieldNotFound: |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
98 |
# no editable relation |
35cd057339b2
turn all the stuff used to handle 'generic relations' in forms into proper
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
99 |
pass |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
100 |
self.maxrelitems = self._cw.property_value('navigation.related-limit') |
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
101 |
self.force_display = bool(self._cw.form.get('__force_display')) |
3874
7d0d4a6be046
[formfields] allow fields ordering with autoform_field_kwargs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3689
diff
changeset
|
102 |
fnum = len(self.fields) |
7d0d4a6be046
[formfields] allow fields ordering with autoform_field_kwargs
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3689
diff
changeset
|
103 |
self.fields.sort(key=lambda f: f.order is None and fnum or f.order) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
104 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
105 |
@property |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
106 |
def related_limit(self): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
107 |
if self.force_display: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
108 |
return None |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
109 |
return self.maxrelitems + 1 |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
110 |
|
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
111 |
@property |
4164
119a374c5eb4
form_add_hidden -> add_hidden
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4160
diff
changeset
|
112 |
def needs_multipart(self): |
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
113 |
"""true if the form needs enctype=multipart/form-data""" |
3470
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
114 |
return self._subform_needs_multipart() |
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
115 |
|
3518
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
116 |
def build_context(self, rendervalues=None): |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
117 |
super(AutomaticEntityForm, self).build_context(rendervalues) |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
118 |
for form in self.inlined_forms(): |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
119 |
form.build_context(rendervalues) |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
120 |
|
3470
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
121 |
def _subform_needs_multipart(self, _tested=None): |
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
122 |
if _tested is None: |
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
123 |
_tested = set() |
4164
119a374c5eb4
form_add_hidden -> add_hidden
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4160
diff
changeset
|
124 |
if super(AutomaticEntityForm, self).needs_multipart: |
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
125 |
return True |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
126 |
# take a look at inlined forms to check (recursively) if they |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
127 |
# need multipart handling. |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
128 |
# XXX: this is very suboptimal because inlined forms will be |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
129 |
# selected / instantiated twice : here and during form rendering. |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
130 |
# Potential solutions: |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
131 |
# -> use subforms for inlined forms to get easiser access |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
132 |
# -> use a simple onload js function to check if there is |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
133 |
# a input type=file in the form |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
134 |
# -> generate the <form> node when the content is rendered |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
135 |
# and we know the correct enctype (formrenderer's w attribute |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
136 |
# is not a StringIO) |
3594
c5b40ab4ea43
rewrite form_needs_multipart using precomputed form views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3593
diff
changeset
|
137 |
for formview in self.inlined_form_views(): |
c5b40ab4ea43
rewrite form_needs_multipart using precomputed form views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3593
diff
changeset
|
138 |
if formview.form: |
c5b40ab4ea43
rewrite form_needs_multipart using precomputed form views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3593
diff
changeset
|
139 |
if hasattr(formview.form, '_subform_needs_multipart'): |
c5b40ab4ea43
rewrite form_needs_multipart using precomputed form views
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3593
diff
changeset
|
140 |
needs_multipart = formview.form._subform_needs_multipart(_tested) |
3470
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
141 |
else: |
4164
119a374c5eb4
form_add_hidden -> add_hidden
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4160
diff
changeset
|
142 |
needs_multipart = formview.form.needs_multipart |
3470
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
143 |
if needs_multipart: |
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
144 |
return True |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
145 |
return False |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
146 |
|
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
147 |
def action(self): |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
148 |
"""return the form's action attribute. Default to validateform if not |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
149 |
explicitly overriden. |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
150 |
""" |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
151 |
try: |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
152 |
return self._action |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
153 |
except AttributeError: |
3457
0924d0d08d60
[api] __regid__, cw_* and friends
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
154 |
return self._cw.build_url('validateform') |
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
155 |
|
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
156 |
def set_action(self, value): |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
157 |
"""override default action""" |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
158 |
self._action = value |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
159 |
|
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
160 |
action = property(action, set_action) |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
161 |
|
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
162 |
# methods mapping edited entity relations to fields in the form ############ |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
163 |
|
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
164 |
def _relations_by_section(self, section, permission='add', strict=False): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
165 |
"""return a list of (relation schema, target schemas, role) matching |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
166 |
given category(ies) and permission |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
167 |
""" |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
168 |
return _afs.relations_by_section( |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
169 |
self.edited_entity, self.formtype, section, permission, strict) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
170 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
171 |
def editable_attributes(self, strict=False): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
172 |
"""return a list of (relation schema, role) to edit for the entity""" |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
173 |
if self.display_fields is not None: |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
174 |
return self.display_fields |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
175 |
# XXX we should simply put eid in the generated section, no? |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
176 |
return [(rtype, role) for rtype, _, role in self._relations_by_section( |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
177 |
'attributes', strict=strict) if rtype != 'eid'] |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
178 |
|
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
179 |
def editable_relations(self): |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
180 |
"""return a sorted list of (relation's label, relation'schema, role) for |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
181 |
relations in the 'relations' section |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
182 |
""" |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
183 |
result = [] |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
184 |
for rschema, _, role in self._relations_by_section('relations', |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
185 |
strict=True): |
3505
c0c7a944c00d
fix dumb name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3503
diff
changeset
|
186 |
result.append( (rschema.display_name(self.edited_entity._cw, role, |
c0c7a944c00d
fix dumb name error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3503
diff
changeset
|
187 |
self.edited_entity.__regid__), |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
188 |
rschema, role) ) |
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
189 |
return sorted(result) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
190 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
191 |
def inlined_relations(self): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
192 |
"""return a list of (relation schema, target schemas, role) matching |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
193 |
given category(ies) and permission |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
194 |
""" |
3476
6e927b729ae1
[uicfg, autoform] more consistent/powerful autoform_section rtags by using formtype/section; deprecates autoform_is_inlined; refactor automatci form and renderer thanks to this
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3468
diff
changeset
|
195 |
return self._relations_by_section('inlined') |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
196 |
|
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
197 |
# generic relations modifier ############################################### |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
198 |
|
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
199 |
# inlined forms support #################################################### |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
200 |
|
3518
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
201 |
@cached |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
202 |
def inlined_form_views(self): |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
203 |
"""compute and return list of inlined form views (hosting the inlined form object) |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
204 |
""" |
3593
987232bd79cd
fix inlined forms initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3586
diff
changeset
|
205 |
allformviews = [] |
3518
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
206 |
entity = self.edited_entity |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
207 |
for rschema, ttypes, role in self.inlined_relations(): |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
208 |
# show inline forms only if there's one possible target type |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
209 |
# for rschema |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
210 |
if len(ttypes) != 1: |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
211 |
self.warning('entity related by the %s relation should have ' |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
212 |
'inlined form but there is multiple target types, ' |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
213 |
'dunno what to do', rschema) |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
214 |
continue |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
215 |
ttype = ttypes[0].type |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
216 |
if self.should_inline_relation_form(rschema, ttype, role): |
3593
987232bd79cd
fix inlined forms initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3586
diff
changeset
|
217 |
formviews = list(self.inline_edition_form_view(rschema, ttype, role)) |
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4082
diff
changeset
|
218 |
card = rschema.rdef(entity.e_schema, ttype).role_cardinality(role) |
3518
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
219 |
# there is no related entity and we need at least one: we need to |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
220 |
# display one explicit inline-creation view |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
221 |
if self.should_display_inline_creation_form(rschema, formviews, card): |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
222 |
formviews += self.inline_creation_form_view(rschema, ttype, role) |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
223 |
# we can create more than one related entity, we thus display a link |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
224 |
# to add new related entities |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
225 |
if self.should_display_add_new_relation_link(rschema, formviews, card): |
4083
3b285889b8e9
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4082
diff
changeset
|
226 |
addnewlink = self._cw.vreg['views'].select( |
4082
c7117119e215
3.6 api update
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4015
diff
changeset
|
227 |
'inline-addnew-link', self._cw, |
3518
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
228 |
etype=ttype, rtype=rschema, role=role, |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
229 |
peid=self.edited_entity.eid, pform=self, card=card) |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
230 |
formviews.append(addnewlink) |
3593
987232bd79cd
fix inlined forms initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3586
diff
changeset
|
231 |
allformviews += formviews |
987232bd79cd
fix inlined forms initialization
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3586
diff
changeset
|
232 |
return allformviews |
3518
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
233 |
|
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
234 |
def inlined_forms(self): |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
235 |
for formview in self.inlined_form_views(): |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
236 |
if formview.form: # may be None for the addnew_link artefact form |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
237 |
yield formview.form |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
238 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
239 |
def should_inline_relation_form(self, rschema, targettype, role): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
240 |
"""return true if the given relation with entity has role and a |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
241 |
targettype target should be inlined |
3483
feedfe5d4932
[autoform] no need to recheck inlined tag here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3482
diff
changeset
|
242 |
|
feedfe5d4932
[autoform] no need to recheck inlined tag here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3482
diff
changeset
|
243 |
At this point we now relation has inlined_attributes tag (eg is returned |
feedfe5d4932
[autoform] no need to recheck inlined tag here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3482
diff
changeset
|
244 |
by `inlined_relations()`. Overrides this for more finer control. |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
245 |
""" |
3595
b61f1c5e6c55
at this point we know this is true
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3594
diff
changeset
|
246 |
return True |
3358
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
247 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
248 |
def should_display_inline_creation_form(self, rschema, existant, card): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
249 |
"""return true if a creation form should be inlined |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
250 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
251 |
by default true if there is no related entity and we need at least one |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
252 |
""" |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
253 |
return not existant and card in '1+' or self._cw.form.has_key('force_%s_display' % rschema) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
254 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
255 |
def should_display_add_new_relation_link(self, rschema, existant, card): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
256 |
"""return true if we should add a link to add a new creation form |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
257 |
(through ajax call) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
258 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
259 |
by default true if there is no related entity or if the relation has |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
260 |
multiple cardinality |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
261 |
""" |
4160 | 262 |
return not existant or card in '+*' # XXX add target type permisssions |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
263 |
|
3332
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
264 |
def should_hide_add_new_relation_link(self, rschema, card): |
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
265 |
"""return true if once an inlined creation form is added, the 'add new' |
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
266 |
link should be hidden |
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
267 |
|
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
268 |
by default true if the relation has single cardinality |
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
269 |
""" |
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
270 |
return card in '1?' |
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
271 |
|
3518
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
272 |
def inline_edition_form_view(self, rschema, ttype, role): |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
273 |
"""yield inline form views for already related entities through the |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
274 |
given relation |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
275 |
""" |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
276 |
entity = self.edited_entity |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
277 |
related = entity.has_eid() and entity.related(rschema, role) |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
278 |
if related: |
3524 | 279 |
vvreg = self._cw.vreg['views'] |
3518
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
280 |
# display inline-edition view for all existing related entities |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
281 |
for i, relentity in enumerate(related.entities()): |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
282 |
if relentity.has_perm('update'): |
3589 | 283 |
yield vvreg.select('inline-edition', self._cw, rset=related, |
3518
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
284 |
row=i, col=0, rtype=rschema, role=role, |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
285 |
peid=entity.eid, pform=self) |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
286 |
|
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
287 |
def inline_creation_form_view(self, rschema, ttype, role): |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
288 |
"""yield inline form views to a newly related (hence created) entity |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
289 |
through the given relation |
11ce4682187d
[form] important refactoring of inlined forms to get proper separation of form object creation / rendering
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3470
diff
changeset
|
290 |
""" |
3524 | 291 |
yield self._cw.vreg['views'].select('inline-creation', self._cw, |
292 |
etype=ttype, rtype=rschema, role=role, |
|
293 |
peid=self.edited_entity.eid, pform=self) |
|
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
294 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
295 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
296 |
## default form ui configuration ############################################## |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
297 |
|
3655
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
298 |
_afs = uicfg.autoform_section |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
299 |
# use primary and not generated for eid since it has to be an hidden |
3655
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
300 |
_afs.tag_attribute(('*', 'eid'), 'main', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
301 |
_afs.tag_attribute(('*', 'eid'), 'muledit', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
302 |
_afs.tag_attribute(('*', 'description'), 'main', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
303 |
_afs.tag_attribute(('*', 'creation_date'), 'main', 'metadata') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
304 |
_afs.tag_attribute(('*', 'modification_date'), 'main', 'metadata') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
305 |
_afs.tag_attribute(('*', 'cwuri'), 'main', 'metadata') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
306 |
_afs.tag_attribute(('*', 'has_text'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
307 |
_afs.tag_subject_of(('*', 'in_state', '*'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
308 |
_afs.tag_subject_of(('*', 'owned_by', '*'), 'main', 'metadata') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
309 |
_afs.tag_subject_of(('*', 'created_by', '*'), 'main', 'metadata') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
310 |
_afs.tag_subject_of(('*', 'require_permission', '*'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
311 |
_afs.tag_subject_of(('*', 'by_transition', '*'), 'main', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
312 |
_afs.tag_subject_of(('*', 'by_transition', '*'), 'muledit', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
313 |
_afs.tag_object_of(('*', 'by_transition', '*'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
314 |
_afs.tag_object_of(('*', 'from_state', '*'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
315 |
_afs.tag_object_of(('*', 'to_state', '*'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
316 |
_afs.tag_subject_of(('*', 'wf_info_for', '*'), 'main', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
317 |
_afs.tag_subject_of(('*', 'wf_info_for', '*'), 'muledit', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
318 |
_afs.tag_object_of(('*', 'wf_info_for', '*'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
319 |
_afs.tag_subject_of(('*', 'for_user', '*'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
320 |
_afs.tag_object_of(('*', 'for_user', '*'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
321 |
_afs.tag_subject_of(('CWPermission', 'require_group', '*'), 'main', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
322 |
_afs.tag_subject_of(('CWPermission', 'require_group', '*'), 'muledit', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
323 |
_afs.tag_attribute(('CWEType', 'final'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
324 |
_afs.tag_attribute(('CWRType', 'final'), 'main', 'hidden') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
325 |
_afs.tag_attribute(('CWUser', 'firstname'), 'main', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
326 |
_afs.tag_attribute(('CWUser', 'surname'), 'main', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
327 |
_afs.tag_attribute(('CWUser', 'last_login_time'), 'main', 'metadata') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
328 |
_afs.tag_subject_of(('CWUser', 'in_group', '*'), 'main', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
329 |
_afs.tag_subject_of(('CWUser', 'in_group', '*'), 'muledit', 'attributes') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
330 |
_afs.tag_subject_of(('*', 'primary_email', '*'), 'main', 'relations') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
331 |
_afs.tag_subject_of(('*', 'use_email', '*'), 'main', 'inlined') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
332 |
_afs.tag_subject_of(('CWRelation', 'relation_type', '*'), 'main', 'inlined') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
333 |
_afs.tag_subject_of(('CWRelation', 'from_entity', '*'), 'main', 'inlined') |
af86ab65a282
3.6 updates
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3629
diff
changeset
|
334 |
_afs.tag_subject_of(('CWRelation', 'to_entity', '*'), 'main', 'inlined') |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
335 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
336 |
uicfg.autoform_field_kwargs.tag_attribute(('RQLExpression', 'expression'), |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
337 |
{'widget': fwdgs.TextInput}) |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
338 |
uicfg.autoform_field_kwargs.tag_subject_of(('TrInfo', 'wf_info_for', '*'), |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
339 |
{'widget': fwdgs.HiddenInput}) |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
340 |
|
4105
de31c3afe975
fix 3.6 bug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
341 |
def registration_callback(vreg): |
de31c3afe975
fix 3.6 bug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
342 |
global etype_relation_field |
de31c3afe975
fix 3.6 bug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
343 |
|
de31c3afe975
fix 3.6 bug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
344 |
def etype_relation_field(etype, rtype, role='subject'): |
de31c3afe975
fix 3.6 bug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
345 |
eschema = vreg.schema.eschema(etype) |
de31c3afe975
fix 3.6 bug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4083
diff
changeset
|
346 |
return AutomaticEntityForm.field_by_name(rtype, role, eschema) |
4110 | 347 |
|
348 |
vreg.register_all(globals().values(), __name__) |