author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Mon, 28 Sep 2009 12:37:01 +0200 | |
changeset 3503 | 06bced8edddf |
parent 3485 | e867ae952fc0 |
parent 3470 | c9c8b231db7b |
child 3505 | c0c7a944c00d |
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 |
1977
606923dff11b
big bunch of copyright / docstring update
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
1969
diff
changeset
|
4 |
:copyright: 2001-2009 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 |
""" |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
8 |
__docformat__ = "restructuredtext en" |
1702 | 9 |
_ = unicode |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
10 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
11 |
from logilab.common.decorators import iclassmethod |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
12 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
13 |
from cubicweb import typed_eid |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
14 |
from cubicweb.web import stdmsgs, uicfg |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
15 |
from cubicweb.web import form, formwidgets as fwdgs |
1498
2c6eec0b46b9
fix imports, cleanup, repair some ajax calls
sylvain.thenault@logilab.fr
parents:
1491
diff
changeset
|
16 |
from cubicweb.web.formfields import guess_field |
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
|
17 |
from cubicweb.web.views import forms, editforms |
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 |
# class attributes below are actually stored in the uicfg module since we |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
47 |
# don't want them to be reloaded |
1739 | 48 |
rfields = uicfg.autoform_field |
1754
c9c7618a90de
autoform_widget superseeded by autoform_field_kwargs (api change addiction :-/)
sylvain.thenault@logilab.fr
parents:
1752
diff
changeset
|
49 |
rfields_kwargs = uicfg.autoform_field_kwargs |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
50 |
|
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
51 |
# class methods mapping schema relations to fields in the form ############ |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
52 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
53 |
@iclassmethod |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
54 |
def field_by_name(cls_or_self, name, role='subject', eschema=None): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
55 |
"""return field with the given name and role. If field is not explicitly |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
56 |
defined for the form but `eclass` is specified, guess_field will be |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
57 |
called. |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
58 |
""" |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
59 |
try: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
60 |
return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
61 |
except form.FieldNotFound: |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3418
diff
changeset
|
62 |
if eschema is None or not name in cls_or_self._cw.schema: |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
63 |
raise |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3418
diff
changeset
|
64 |
rschema = cls_or_self._cw.schema.rschema(name) |
1743
591cff8f0701
take a sample target type instead of '*' else we may miss some expected values (we may still miss some...)
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
65 |
# XXX use a sample target type. Document this. |
591cff8f0701
take a sample target type instead of '*' else we may miss some expected values (we may still miss some...)
sylvain.thenault@logilab.fr
parents:
1739
diff
changeset
|
66 |
tschemas = rschema.targets(eschema, role) |
2096 | 67 |
fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role, |
68 |
tschemas[0]) |
|
69 |
kwargs = cls_or_self.rfields_kwargs.etype_get(eschema, rschema, |
|
70 |
role, tschemas[0]) |
|
1782
aa7136519c19
consider fields_kwargs even when field specified
sylvain.thenault@logilab.fr
parents:
1754
diff
changeset
|
71 |
if kwargs is None: |
aa7136519c19
consider fields_kwargs even when field specified
sylvain.thenault@logilab.fr
parents:
1754
diff
changeset
|
72 |
kwargs = {} |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
73 |
if fieldcls: |
1788
d6e6ad70e50a
check field isn't already instantiated
sylvain.thenault@logilab.fr
parents:
1782
diff
changeset
|
74 |
if not isinstance(fieldcls, type): |
d6e6ad70e50a
check field isn't already instantiated
sylvain.thenault@logilab.fr
parents:
1782
diff
changeset
|
75 |
return fieldcls # already and instance |
1782
aa7136519c19
consider fields_kwargs even when field specified
sylvain.thenault@logilab.fr
parents:
1754
diff
changeset
|
76 |
return fieldcls(name=name, role=role, eidparam=True, **kwargs) |
aa7136519c19
consider fields_kwargs even when field specified
sylvain.thenault@logilab.fr
parents:
1754
diff
changeset
|
77 |
field = guess_field(eschema, rschema, role, eidparam=True, **kwargs) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
78 |
if field is None: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
79 |
raise |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
80 |
return field |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
81 |
|
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
82 |
# base automatic entity form methods ####################################### |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
83 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
84 |
def __init__(self, *args, **kwargs): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
85 |
super(AutomaticEntityForm, self).__init__(*args, **kwargs) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
86 |
entity = self.edited_entity |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
87 |
if entity.has_eid(): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
88 |
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
|
89 |
for rtype, role in self.editable_attributes(): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
90 |
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
|
91 |
self.field_by_name(str(rtype), role) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
92 |
continue # explicitly specified |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
93 |
except form.FieldNotFound: |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
94 |
# has to be guessed |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
95 |
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
|
96 |
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
|
97 |
eschema=entity.e_schema) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
98 |
self.fields.append(field) |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
99 |
except form.FieldNotFound: |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
100 |
# meta attribute such as <attr>_format |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
101 |
continue |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
102 |
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
|
103 |
self.force_display = bool(self._cw.form.get('__force_display')) |
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 |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
112 |
def form_needs_multipart(self): |
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 |
|
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
116 |
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
|
117 |
if _tested is None: |
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
118 |
_tested = set() |
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
119 |
if super(AutomaticEntityForm, self).form_needs_multipart: |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
120 |
return True |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
121 |
# 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
|
122 |
# need multipart handling. |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
123 |
# XXX: this is very suboptimal because inlined forms will be |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
124 |
# selected / instantiated twice : here and during form rendering. |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
125 |
# Potential solutions: |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
126 |
# -> use subforms for inlined forms to get easiser access |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
127 |
# -> 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
|
128 |
# a input type=file in the form |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
129 |
# -> generate the <form> node when the content is rendered |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
130 |
# and we know the correct enctype (formrenderer's w attribute |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
131 |
# is not a StringIO) |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
132 |
for rschema, targettypes, role in self.inlined_relations(): |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
133 |
# inlined forms don't handle multiple target types |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
134 |
if len(targettypes) != 1: |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
135 |
continue |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
136 |
targettype = targettypes[0] |
3470
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
137 |
if targettype in _tested: |
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
138 |
continue |
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
139 |
_tested.add(targettype) |
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
140 |
if self.should_inline_relation_form(rschema, targettype, role): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3418
diff
changeset
|
141 |
entity = self._cw.vreg['etypes'].etype_class(targettype)(self._cw) |
3485 | 142 |
subform = self._cw.vreg['forms'].select('edition', self._cw, |
143 |
entity=entity) |
|
3470
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
144 |
if hasattr(subform, '_subform_needs_multipart'): |
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
145 |
needs_multipart = subform._subform_needs_multipart(_tested) |
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
146 |
else: |
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
147 |
needs_multipart = subform.form_needs_multipart |
c9c8b231db7b
[forms] fix form_needs_multipart implementation
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3360
diff
changeset
|
148 |
if needs_multipart: |
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
149 |
return True |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
150 |
return False |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
151 |
|
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
152 |
def action(self): |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
153 |
"""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
|
154 |
explicitly overriden. |
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 |
try: |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
157 |
return self._action |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
158 |
except AttributeError: |
3457
0924d0d08d60
[api] __regid__, cw_* and friends
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3451
diff
changeset
|
159 |
return self._cw.build_url('validateform') |
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
160 |
|
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
161 |
def set_action(self, value): |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
162 |
"""override default action""" |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
163 |
self._action = value |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
164 |
|
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
165 |
action = property(action, set_action) |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
166 |
|
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
167 |
# methods mapping edited entity relations to fields in the form ############ |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
168 |
|
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
|
169 |
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
|
170 |
"""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
|
171 |
given category(ies) and permission |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
172 |
""" |
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
|
173 |
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
|
174 |
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
|
175 |
|
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 |
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
|
177 |
"""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
|
178 |
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
|
179 |
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
|
180 |
# 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
|
181 |
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
|
182 |
'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
|
183 |
|
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 |
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
|
185 |
"""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
|
186 |
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
|
187 |
""" |
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 |
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
|
189 |
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
|
190 |
strict=True): |
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
|
191 |
result.append( (rschema.display_name(entity._cw, 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
|
192 |
entity.__regid__), |
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
|
193 |
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
|
194 |
return sorted(result) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
195 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
196 |
def inlined_relations(self): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
197 |
"""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
|
198 |
given category(ies) and permission |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
199 |
""" |
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
|
200 |
return self._relations_by_section('inlined') |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
201 |
|
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
202 |
# generic relations modifier ############################################### |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
203 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
204 |
def relations_table(self): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
205 |
"""yiels 3-tuples (rtype, target, related_list) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
206 |
where <related_list> itself a list of : |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
207 |
- node_id (will be the entity element's DOM id) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
208 |
- appropriate javascript's togglePendingDelete() function call |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
209 |
- status 'pendingdelete' or '' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
210 |
- oneline view of related entity |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
211 |
""" |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
212 |
entity = self.edited_entity |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
213 |
pending_deletes = self._cw.get_pending_deletes(entity.eid) |
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
|
214 |
for label, rschema, role in self.editable_relations(): |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
215 |
relatedrset = entity.related(rschema, role, limit=self.related_limit) |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
216 |
if rschema.has_perm(self._cw, 'delete'): |
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
|
217 |
toggleable_rel_link_func = editforms.toggleable_relation_link |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
218 |
else: |
1528
864ae7c15ef5
other fixlets
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1498
diff
changeset
|
219 |
toggleable_rel_link_func = lambda x, y, z: u'' |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
220 |
related = [] |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
221 |
for row in xrange(relatedrset.rowcount): |
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
|
222 |
nodeid = editforms.relation_id(entity.eid, rschema, role, |
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
|
223 |
relatedrset[row][0]) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
224 |
if nodeid in pending_deletes: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
225 |
status = u'pendingDelete' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
226 |
label = '+' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
227 |
else: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
228 |
status = u'' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
229 |
label = 'x' |
1528
864ae7c15ef5
other fixlets
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
1498
diff
changeset
|
230 |
dellink = toggleable_rel_link_func(entity.eid, nodeid, label) |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
231 |
eview = self._cw.view('oneline', relatedrset, row=row) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
232 |
related.append((nodeid, dellink, status, eview)) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
233 |
yield (rschema, role, related) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
234 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
235 |
def restore_pending_inserts(self, cell=False): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
236 |
"""used to restore edition page as it was before clicking on |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
237 |
'search for <some entity type>' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
238 |
""" |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
239 |
eid = self.edited_entity.eid |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
240 |
cell = cell and "div_insert_" or "tr" |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
241 |
pending_inserts = set(self._cw.get_pending_inserts(eid)) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
242 |
for pendingid in pending_inserts: |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
243 |
eidfrom, rtype, eidto = pendingid.split(':') |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
244 |
if typed_eid(eidfrom) == eid: # subject |
3482
9a868f462fa4
[i18n] properly give context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
245 |
label = display_name(self._cw, rtype, 'subject', |
9a868f462fa4
[i18n] properly give context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
246 |
self.edited_entity.__regid__) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
247 |
reid = eidto |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
248 |
else: |
3482
9a868f462fa4
[i18n] properly give context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
249 |
label = display_name(self._cw, rtype, 'object', |
9a868f462fa4
[i18n] properly give context
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3481
diff
changeset
|
250 |
self.edited_entity.__regid__) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
251 |
reid = eidfrom |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
252 |
jscall = "javascript: cancelPendingInsert('%s', '%s', null, %s);" \ |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
253 |
% (pendingid, cell, eid) |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
254 |
rset = self._cw.eid_rset(reid) |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
255 |
eview = self._cw.view('text', rset, row=0) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
256 |
# XXX find a clean way to handle baskets |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
257 |
if rset.description[0][0] == 'Basket': |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
258 |
eview = '%s (%s)' % (eview, display_name(self._cw, 'Basket')) |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
259 |
yield rtype, pendingid, jscall, label, reid, eview |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
260 |
|
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
261 |
# inlined forms support #################################################### |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
262 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
263 |
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
|
264 |
"""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
|
265 |
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
|
266 |
|
feedfe5d4932
[autoform] no need to recheck inlined tag here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3482
diff
changeset
|
267 |
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
|
268 |
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
|
269 |
""" |
3483
feedfe5d4932
[autoform] no need to recheck inlined tag here
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3482
diff
changeset
|
270 |
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
|
271 |
|
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
272 |
def display_inline_edition_form(self, w, rschema, targettype, role, |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
273 |
i18nctx): |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
274 |
"""display inline forms for already related entities. |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
275 |
|
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
276 |
Return True if some inlined form are actually displayed |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
277 |
""" |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
278 |
existant = False |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
279 |
entity = self.edited_entity |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
280 |
related = entity.has_eid() and entity.related(rschema, role) |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
281 |
if related: |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
282 |
# display inline-edition view for all existing related entities |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
283 |
for i, relentity in enumerate(related.entities()): |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
284 |
if relentity.has_perm('update'): |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
285 |
w(self._cw.view('inline-edition', related, row=i, col=0, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
286 |
rtype=rschema, role=role, ptype=entity.e_schema, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
287 |
peid=entity.eid, i18nctx=i18nctx)) |
3358
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
288 |
existant = True |
0cddc4d8cad8
[forms] do similar refactoring for inline edition than for inline creation
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3356
diff
changeset
|
289 |
return existant |
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
290 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
291 |
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
|
292 |
"""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
|
293 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
294 |
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
|
295 |
""" |
3418
7b49fa7e942d
[api] use _cw, cw_row, cw_col, cw_rset etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3408
diff
changeset
|
296 |
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
|
297 |
|
3356
9ca73fbd3a58
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3341
diff
changeset
|
298 |
def display_inline_creation_form(self, w, rschema, targettype, role, |
9ca73fbd3a58
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3341
diff
changeset
|
299 |
i18nctx): |
3360
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
300 |
"""display inline forms to a newly related (hence created) entity. |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
301 |
|
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
302 |
Return True if some inlined form are actually displayed |
b02df886eb3e
cleanup, reorganize
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3358
diff
changeset
|
303 |
""" |
3356
9ca73fbd3a58
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3341
diff
changeset
|
304 |
entity = self.edited_entity |
3468
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
305 |
w(self._cw.view('inline-creation', None, etype=targettype, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
306 |
peid=entity.eid, ptype=entity.e_schema, |
b02fa4db2868
[tests] make unittest_viewselectors pass again
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3457
diff
changeset
|
307 |
rtype=rschema, role=role, i18nctx=i18nctx)) |
3356
9ca73fbd3a58
refactor to ease overriding
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3341
diff
changeset
|
308 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
309 |
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
|
310 |
"""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
|
311 |
(through ajax call) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
312 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
313 |
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
|
314 |
multiple cardinality |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
315 |
""" |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
316 |
return not existant or card in '+*' |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
317 |
|
3332
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
318 |
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
|
319 |
"""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
|
320 |
link should be hidden |
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
321 |
|
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
322 |
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
|
323 |
""" |
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
324 |
return card in '1?' |
91cff87c368f
introduced to ease overriding for fancy stuff...
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3293
diff
changeset
|
325 |
|
1491
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
326 |
|
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
327 |
def etype_relation_field(etype, rtype, role='subject'): |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
328 |
eschema = AutomaticEntityForm.schema.eschema(etype) |
742aff97dbf7
move AutomaticEntityForm and PrimaryView into their own module
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
329 |
return AutomaticEntityForm.field_by_name(rtype, role, eschema) |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
330 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
331 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
332 |
## default form ui configuration ############################################## |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
333 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
334 |
# use primary and not generated for eid since it has to be an hidden |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
335 |
uicfg.autoform_section.tag_attribute(('*', 'eid'), 'primary') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
336 |
uicfg.autoform_section.tag_attribute(('*', 'description'), 'secondary') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
337 |
uicfg.autoform_section.tag_attribute(('*', 'creation_date'), 'metadata') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
338 |
uicfg.autoform_section.tag_attribute(('*', 'modification_date'), 'metadata') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
339 |
uicfg.autoform_section.tag_attribute(('*', 'cwuri'), 'metadata') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
340 |
uicfg.autoform_section.tag_subject_of(('*', 'in_state', '*'), 'primary') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
341 |
uicfg.autoform_section.tag_subject_of(('*', 'owned_by', '*'), 'metadata') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
342 |
uicfg.autoform_section.tag_subject_of(('*', 'created_by', '*'), 'metadata') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
343 |
uicfg.autoform_section.tag_subject_of(('*', 'require_permission', '*'), 'generated') |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
344 |
uicfg.autoform_section.tag_subject_of(('*', 'by_transition', '*'), 'primary') |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
345 |
uicfg.autoform_section.tag_object_of(('*', 'by_transition', '*'), 'generated') |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
346 |
uicfg.autoform_section.tag_object_of(('*', 'from_state', '*'), 'generated') |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
347 |
uicfg.autoform_section.tag_object_of(('*', 'to_state', '*'), 'generated') |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
348 |
uicfg.autoform_section.tag_subject_of(('*', 'wf_info_for', '*'), 'primary') |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
349 |
uicfg.autoform_section.tag_object_of(('*', 'wf_info_for', '*'), 'generated') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
350 |
uicfg.autoform_section.tag_subject_of(('*', 'for_user', '*'), 'generated') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
351 |
uicfg.autoform_section.tag_object_of(('*', 'for_user', '*'), 'generated') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
352 |
uicfg.autoform_section.tag_subject_of(('CWPermission', 'require_group', '*'), 'primary') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
353 |
uicfg.autoform_section.tag_attribute(('CWEType', 'final'), 'generated') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
354 |
uicfg.autoform_section.tag_attribute(('CWRType', 'final'), 'generated') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
355 |
uicfg.autoform_section.tag_attribute(('CWUser', 'firstname'), 'secondary') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
356 |
uicfg.autoform_section.tag_attribute(('CWUser', 'surname'), 'secondary') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
357 |
uicfg.autoform_section.tag_attribute(('CWUser', 'last_login_time'), 'metadata') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
358 |
uicfg.autoform_section.tag_subject_of(('CWUser', 'in_group', '*'), 'primary') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
359 |
uicfg.autoform_section.tag_object_of(('*', 'bookmarked_by', 'CWUser'), 'metadata') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
360 |
uicfg.autoform_section.tag_attribute(('Bookmark', 'path'), 'primary') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
361 |
uicfg.autoform_section.tag_subject_of(('*', 'primary_email', '*'), 'generic') |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
362 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
363 |
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
|
364 |
{'widget': fwdgs.TextInput}) |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
365 |
uicfg.autoform_field_kwargs.tag_attribute(('Bookmark', 'path'), |
2920
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
366 |
{'widget': fwdgs.TextInput}) |
64322aa83a1d
start a new workflow engine
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2780
diff
changeset
|
367 |
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
|
368 |
{'widget': fwdgs.HiddenInput}) |
2652
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
369 |
|
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
370 |
uicfg.autoform_is_inlined.tag_subject_of(('*', 'use_email', '*'), True) |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
371 |
uicfg.autoform_is_inlined.tag_subject_of(('CWRelation', 'relation_type', '*'), True) |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
372 |
uicfg.autoform_is_inlined.tag_subject_of(('CWRelation', 'from_entity', '*'), True) |
3753f3a07ca1
[refactoring] moved rtags specification in web/views
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
2143
diff
changeset
|
373 |
uicfg.autoform_is_inlined.tag_subject_of(('CWRelation', 'to_entity', '*'), True) |