author | Laurent Peuch <cortex@worlddomination.be> |
Thu, 21 Feb 2019 18:48:07 +0100 | |
changeset 12391 | e4e5814fd70c |
parent 10491 | c67bcee93248 |
child 12879 | 7347715bf0ee |
permissions | -rw-r--r-- |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
1 |
.. _reledit: |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
2 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
3 |
The "Click and Edit" (also `reledit`) View |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
4 |
------------------------------------------ |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
5 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
6 |
The principal way to update data through the Web UI is through the |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
7 |
`modify` action on entities, which brings a full form. This is |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
8 |
described in the :ref:`webform` chapter. |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
9 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
10 |
There is however another way to perform piecewise edition of entities |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
11 |
and relations, using a specific `reledit` (for *relation edition*) |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
12 |
view from the :mod:`cubicweb.web.views.reledit` module. |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
13 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
14 |
This is typically applied from the default Primary View (see |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
15 |
:ref:`primary_view`) on the attributes and relation section. It makes |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
16 |
small editions more convenient. |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
17 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
18 |
Of course, this can be used customely in any other view. Here come |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
19 |
some explanation about its capabilities and instructions on the way to |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
20 |
use it. |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
21 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
22 |
Using `reledit` |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
23 |
*************** |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
24 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
25 |
Let's start again with a simple example: |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
26 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
27 |
.. sourcecode:: python |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
28 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
29 |
class Company(EntityType): |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
30 |
name = String(required=True, unique=True) |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
31 |
boss = SubjectRelation('Person', cardinality='1*') |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
32 |
status = SubjectRelation('File', cardinality='?*', composite='subject') |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
33 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
34 |
In some view code we might want to show these attributes/relations and |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
35 |
allow the user to edit each of them in turn without having to leave |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
36 |
the current page. We would write code as below: |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
37 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
38 |
.. sourcecode:: python |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
39 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
40 |
company.view('reledit', rtype='name', default_value='<name>') # editable name attribute |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
41 |
company.view('reledit', rtype='boss') # editable boss relation |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
42 |
company.view('reledit', rtype='status') # editable attribute-like relation |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
43 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
44 |
If one wanted to edit the company from a boss's point of view, one |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
45 |
would have to indicate the proper relation's role. By default the role |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
46 |
is `subject`. |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
47 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
48 |
.. sourcecode:: python |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
49 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
50 |
person.view('reledit', rtype='boss', role='object') |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
51 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
52 |
Each of these will provide with a different editing widget. The `name` |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
53 |
attribute will obviously get a text input field. The `boss` relation |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
54 |
will be edited through a selection box, allowing to pick another |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
55 |
`Person` as boss. The `status` relation, given that it defines Company |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
56 |
as a composite entity with one file inside, will provide additional actions |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
57 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
58 |
* to `add` a `File` when there is one |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
59 |
* to `delete` the `File` (if the cardinality allows it) |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
60 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
61 |
Moreover, editing the relation or using the `add` action leads to an |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
62 |
embedded edition/creation form allowing edition of the target entity |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
63 |
(which is `File` in our example) instead of merely allowing to choose |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
64 |
amongst existing files. |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
65 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
66 |
The `reledit_ctrl` rtag |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
67 |
*********************** |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
68 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
69 |
The behaviour of reledited attributes/relations can be finely |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
70 |
controlled using the reledit_ctrl rtag, defined in |
8665
e65af61bde7d
[uicfg] uicfg.py moves from web/ to web/views/ (prepares #2406609)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7760
diff
changeset
|
71 |
:mod:`cubicweb.web.views.uicfg`. |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
72 |
|
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
73 |
This rtag provides four control variables: |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
74 |
|
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
75 |
* ``default_value``: alternative default value |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
76 |
The default value is what is shown when there is no value. |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
77 |
* ``reload``: boolean, eid (to reload to) or function taking subject |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
78 |
and returning bool/eid This is useful when editing a relation (or |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
79 |
attribute) that impacts the url or another parts of the current |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
80 |
displayed page. Defaults to false. |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
81 |
* ``rvid``: alternative view id (as str) for relation or composite |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
82 |
edition Default is 'incontext' or 'csv' depending on the |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
83 |
cardinality. They can also be statically changed by subclassing |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
84 |
ClickAndEditFormView and redefining _one_rvid (resp. _many_rvid). |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
85 |
* ``edit_target``: 'rtype' (to edit the relation) or 'related' (to |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
86 |
edit the related entity) This controls whether to edit the relation |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
87 |
or the target entity of the relation. Currently only one-to-one |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
88 |
relations support target entity edition. By default, the 'related' |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
89 |
option is taken whenever the relation is composite and one-to-one. |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
90 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
91 |
Let's see how to use these controls. |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
92 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
93 |
.. sourcecode:: python |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
94 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
95 |
from logilab.mtconverter import xml_escape |
8665
e65af61bde7d
[uicfg] uicfg.py moves from web/ to web/views/ (prepares #2406609)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7760
diff
changeset
|
96 |
from cubicweb.web.views.uicfg import reledit_ctrl |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
97 |
reledit_ctrl.tag_attribute(('Company', 'name'), |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
98 |
{'reload': lambda x:x.eid, |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
99 |
'default_value': xml_escape(u'<logilab tastes better>')}) |
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
100 |
reledit_ctrl.tag_object_of(('*', 'boss', 'Person'), {'edit_target': 'related'}) |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
101 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
102 |
The `default_value` needs to be an xml escaped unicode string. |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
103 |
|
6246
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
104 |
The `edit_target` tag on the `boss` relation being set to `related` will |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
105 |
ensure edition of the `Person` entity instead (using a standard |
62e25fac41cd
[views/reledit] refactor composite handling
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5869
diff
changeset
|
106 |
automatic form) of the association of Company and Person. |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
107 |
|
10222
75d6096216d7
[docstrings] fix project-wide English language mistake
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents:
8665
diff
changeset
|
108 |
Finally, the `reload` key accepts either a boolean, an eid or a |
75d6096216d7
[docstrings] fix project-wide English language mistake
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents:
8665
diff
changeset
|
109 |
unicode string representing a url. If an eid is provided, it will be |
75d6096216d7
[docstrings] fix project-wide English language mistake
Dimitri Papadopoulos <dimitri.papadopoulos@cea.fr>
parents:
8665
diff
changeset
|
110 |
internally transformed into a url. The eid/url case helps when one |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
111 |
needs to reload and the current url is inappropriate. A common case is |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
112 |
edition of a key attribute, which is part of the current url. If one |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
113 |
user changed the Company's name from `lozilab` to `logilab`, reloading |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
114 |
on http://myapp/company/lozilab would fail. Providing the entity's |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
115 |
eid, then, forces to reload on something like http://myapp/company/42, |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
116 |
which always work. |
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
117 |
|
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
118 |
|
7759
2cd77f21fd41
[book] section about how to disable reledit feature/view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
119 |
Disable `reledit` |
2cd77f21fd41
[book] section about how to disable reledit feature/view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
120 |
***************** |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
121 |
|
7760
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
122 |
By default, `reledit` is available on attributes and relations displayed in |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
123 |
the 'attribute' section of the default primary view. If you want to disable |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
124 |
it for some attribute or relation, you have use `uicfg`: |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
125 |
|
7759
2cd77f21fd41
[book] section about how to disable reledit feature/view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
126 |
.. sourcecode:: python |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
127 |
|
8665
e65af61bde7d
[uicfg] uicfg.py moves from web/ to web/views/ (prepares #2406609)
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
7760
diff
changeset
|
128 |
from cubicweb.web.views.uicfg import primaryview_display_ctrl as _pvdc |
7759
2cd77f21fd41
[book] section about how to disable reledit feature/view
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6246
diff
changeset
|
129 |
_pvdc.tag_attribute(('Company', 'name'), {'vid': 'incontext'}) |
5869
8a129b3a5aff
reledit refactoring
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
diff
changeset
|
130 |
|
7760
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
131 |
To deactivate it everywhere it's used automatically, you may use the code snippet |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
132 |
below somewhere in your cube's views: |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
133 |
|
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
134 |
.. sourcecode:: python |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
135 |
|
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
136 |
from cubicweb.web.views import reledit |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
137 |
|
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
138 |
class DeactivatedAutoClickAndEditFormView(reledit.AutoClickAndEditFormView): |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
139 |
def _should_edit_attribute(self, rschema): |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
140 |
return False |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
141 |
|
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
142 |
def _should_edit_attribute(self, rschema, role): |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
143 |
return False |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
144 |
|
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
145 |
def registration_callback(vreg): |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
146 |
vreg.register_and_replace(DeactivatedAutoClickAndEditFormView, |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
147 |
reledit.AutoClickAndEditFormView) |
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
148 |
|
75d80ef524c7
oops, forgotten to qref enhancements made to the reledit doc addition
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7759
diff
changeset
|
149 |