author | Sylvain Thénault <sylvain.thenault@logilab.fr> |
Fri, 05 Feb 2010 08:11:32 +0100 | |
changeset 4460 | 5c22869079b9 |
parent 4385 | 820aa03f71ad |
child 4490 | d45cde54d464 |
permissions | -rw-r--r-- |
0 | 1 |
"""abstract box classes for CubicWeb web client |
2 |
||
3 |
:organization: Logilab |
|
4212
ab6573088b4a
update copyright: welcome 2010
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
4205
diff
changeset
|
4 |
:copyright: 2001-2010 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
0 | 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:
1885
diff
changeset
|
6 |
:license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
0 | 7 |
""" |
8 |
__docformat__ = "restructuredtext en" |
|
2159 | 9 |
_ = unicode |
0 | 10 |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2159
diff
changeset
|
11 |
from logilab.mtconverter import xml_escape |
0 | 12 |
|
1149 | 13 |
from cubicweb import Unauthorized, role as get_role, target as get_target |
2710
40789c3044f3
[web.box] remove deprecation warnings
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2381
diff
changeset
|
14 |
from cubicweb.schema import display_name |
652
603c782dc092
various SyntaxErrors / missing import fixes + reorganization of the `registered` classmethod
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
640
diff
changeset
|
15 |
from cubicweb.selectors import (one_line_rset, primary_view, |
2819
b864288fd316
remove more 3.2 deprecated code, reintroduce checkbox used by formrenderers
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2799
diff
changeset
|
16 |
match_context_prop, partial_has_related_entities) |
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
809
diff
changeset
|
17 |
from cubicweb.view import View, ReloadableMixIn |
0 | 18 |
|
4345
06a34ff6b49a
skil internal field value, else we get an error
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4252
diff
changeset
|
19 |
from cubicweb.web import INTERNAL_FIELD_VALUE |
0 | 20 |
from cubicweb.web.htmlwidgets import (BoxLink, BoxWidget, SideBoxWidget, |
250
7fd7a0d387d7
new RelatedEntityBoxTemplate base class
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
21 |
RawBoxItem, BoxSeparator) |
0 | 22 |
from cubicweb.web.action import UnregisteredAction |
23 |
||
24 |
||
816
9cd49a910fce
kill Template class and 'templates' registry
sylvain.thenault@logilab.fr
parents:
809
diff
changeset
|
25 |
class BoxTemplate(View): |
0 | 26 |
"""base template for boxes, usually a (contextual) list of possible |
1493 | 27 |
|
0 | 28 |
actions. Various classes attributes may be used to control the box |
29 |
rendering. |
|
1493 | 30 |
|
0 | 31 |
You may override on of the formatting callbacks is this is not necessary |
32 |
for your custom box. |
|
1493 | 33 |
|
0 | 34 |
Classes inheriting from this class usually only have to override call |
35 |
to fetch desired actions, and then to do something like :: |
|
36 |
||
37 |
box.render(self.w) |
|
38 |
""" |
|
39 |
__registry__ = 'boxes' |
|
809 | 40 |
__select__ = match_context_prop() |
1493 | 41 |
|
0 | 42 |
categories_in_order = () |
2799
b703639614e7
refactor property handling to avoid name conflicts
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2789
diff
changeset
|
43 |
cw_property_defs = { |
0 | 44 |
_('visible'): dict(type='Boolean', default=True, |
45 |
help=_('display the box or not')), |
|
46 |
_('order'): dict(type='Int', default=99, |
|
47 |
help=_('display order of the box')), |
|
48 |
# XXX 'incontext' boxes are handled by the default primary view |
|
49 |
_('context'): dict(type='String', default='left', |
|
50 |
vocabulary=(_('left'), _('incontext'), _('right')), |
|
51 |
help=_('context where this box should be displayed')), |
|
52 |
} |
|
53 |
context = 'left' |
|
54 |
htmlitemclass = 'boxItem' |
|
55 |
||
56 |
def sort_actions(self, actions): |
|
57 |
"""return a list of (category, actions_sorted_by_title)""" |
|
58 |
result = [] |
|
59 |
actions_by_cat = {} |
|
60 |
for action in actions: |
|
3220
11b6016e3970
cleanup, futur warning fixes :)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2757
diff
changeset
|
61 |
actions_by_cat.setdefault(action.category, []).append( |
11b6016e3970
cleanup, futur warning fixes :)
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2757
diff
changeset
|
62 |
(action.title, action) ) |
0 | 63 |
for key, values in actions_by_cat.items(): |
64 |
actions_by_cat[key] = [act for title, act in sorted(values)] |
|
65 |
for cat in self.categories_in_order: |
|
66 |
if cat in actions_by_cat: |
|
67 |
result.append( (cat, actions_by_cat[cat]) ) |
|
68 |
for item in sorted(actions_by_cat.items()): |
|
69 |
result.append(item) |
|
70 |
return result |
|
71 |
||
72 |
def mk_action(self, title, path, escape=True, **kwargs): |
|
73 |
"""factory function to create dummy actions compatible with the |
|
74 |
.format_actions method |
|
75 |
""" |
|
76 |
if escape: |
|
2312
af4d8f75c5db
use xml_escape
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
2159
diff
changeset
|
77 |
title = xml_escape(title) |
0 | 78 |
return self.box_action(self._action(title, path, **kwargs)) |
1493 | 79 |
|
0 | 80 |
def _action(self, title, path, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
81 |
return UnregisteredAction(self._cw, self.cw_rset, title, path, **kwargs) |
0 | 82 |
|
83 |
# formating callbacks |
|
84 |
||
85 |
def boxitem_link_tooltip(self, action): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
86 |
if action.__regid__: |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
87 |
return u'keyword: %s' % action.__regid__ |
0 | 88 |
return u'' |
89 |
||
90 |
def box_action(self, action): |
|
91 |
cls = getattr(action, 'html_class', lambda: None)() or self.htmlitemclass |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
92 |
return BoxLink(action.url(), self._cw._(action.title), |
0 | 93 |
cls, self.boxitem_link_tooltip(action)) |
1493 | 94 |
|
0 | 95 |
|
96 |
class RQLBoxTemplate(BoxTemplate): |
|
97 |
"""abstract box for boxes displaying the content of a rql query not |
|
98 |
related to the current result set. |
|
1493 | 99 |
|
0 | 100 |
It rely on etype, rtype (both optional, usable to control registration |
101 |
according to application schema and display according to connected |
|
102 |
user's rights) and rql attributes |
|
103 |
""" |
|
640
8e64f12be69c
drop EntityAction usage in cw, upgrade rql_condition and friends
sylvain.thenault@logilab.fr
parents:
526
diff
changeset
|
104 |
#XXX __selectors__ = BoxTemplate.__selectors__ + (etype_rtype_selector,) |
0 | 105 |
|
106 |
rql = None |
|
1493 | 107 |
|
0 | 108 |
def to_display_rql(self): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
109 |
assert self.rql is not None, self.__regid__ |
0 | 110 |
return (self.rql,) |
1493 | 111 |
|
0 | 112 |
def call(self, **kwargs): |
113 |
try: |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
114 |
rset = self._cw.execute(*self.to_display_rql()) |
0 | 115 |
except Unauthorized: |
116 |
# can't access to something in the query, forget this box |
|
117 |
return |
|
118 |
if len(rset) == 0: |
|
119 |
return |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
120 |
box = BoxWidget(self._cw._(self.title), self.__regid__) |
0 | 121 |
for i, (teid, tname) in enumerate(rset): |
122 |
entity = rset.get_entity(i, 0) |
|
123 |
box.append(self.mk_action(tname, entity.absolute_url())) |
|
124 |
box.render(w=self.w) |
|
125 |
||
1493 | 126 |
|
0 | 127 |
class UserRQLBoxTemplate(RQLBoxTemplate): |
128 |
"""same as rql box template but the rql is build using the eid of the |
|
129 |
request's user |
|
130 |
""" |
|
131 |
||
132 |
def to_display_rql(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
133 |
assert self.rql is not None, self.__regid__ |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
134 |
return (self.rql, {'x': self._cw.user.eid}, 'x') |
1493 | 135 |
|
0 | 136 |
|
137 |
class EntityBoxTemplate(BoxTemplate): |
|
138 |
"""base class for boxes related to a single entity""" |
|
809 | 139 |
__select__ = BoxTemplate.__select__ & one_line_rset() & primary_view() |
0 | 140 |
context = 'incontext' |
1493 | 141 |
|
0 | 142 |
def call(self, row=0, col=0, **kwargs): |
526 | 143 |
"""classes inheriting from EntityBoxTemplate should define cell_call""" |
0 | 144 |
self.cell_call(row, col, **kwargs) |
145 |
||
146 |
||
250
7fd7a0d387d7
new RelatedEntityBoxTemplate base class
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
147 |
class RelatedEntityBoxTemplate(EntityBoxTemplate): |
838
f2c56312b03a
rename abstract_* selectors into partial_* + add docstrings
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
816
diff
changeset
|
148 |
__select__ = EntityBoxTemplate.__select__ & partial_has_related_entities() |
742
99115e029dca
replaced most of __selectors__ assignments with __select__
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
670
diff
changeset
|
149 |
|
250
7fd7a0d387d7
new RelatedEntityBoxTemplate base class
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
150 |
def cell_call(self, row, col, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
151 |
entity = self.cw_rset.get_entity(row, col) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
152 |
limit = self._cw.property_value('navigation.related-limit') + 1 |
250
7fd7a0d387d7
new RelatedEntityBoxTemplate base class
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
153 |
role = get_role(self) |
1885
c2011d238e98
replace sideRelated with sideBox
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1696
diff
changeset
|
154 |
self.w(u'<div class="sideBox">') |
250
7fd7a0d387d7
new RelatedEntityBoxTemplate base class
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
155 |
self.wview('sidebox', entity.related(self.rtype, role, limit=limit), |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
156 |
title=display_name(self._cw, self.rtype, role)) |
250
7fd7a0d387d7
new RelatedEntityBoxTemplate base class
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
157 |
self.w(u'</div>') |
7fd7a0d387d7
new RelatedEntityBoxTemplate base class
Sylvain Thenault <sylvain.thenault@logilab.fr>
parents:
237
diff
changeset
|
158 |
|
0 | 159 |
|
160 |
class EditRelationBoxTemplate(ReloadableMixIn, EntityBoxTemplate): |
|
161 |
"""base class for boxes which let add or remove entities linked |
|
162 |
by a given relation |
|
163 |
||
164 |
subclasses should define at least id, rtype and target |
|
165 |
class attributes. |
|
166 |
""" |
|
1493 | 167 |
|
1624
baf484a182cd
should take arbitrary arguments
sylvain.thenault@logilab.fr
parents:
1493
diff
changeset
|
168 |
def cell_call(self, row, col, view=None, **kwargs): |
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
169 |
self._cw.add_js('cubicweb.ajax.js') |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
170 |
entity = self.cw_rset.get_entity(row, col) |
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
171 |
box = SideBoxWidget(display_name(self._cw, self.rtype), self.__regid__) |
2757
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
172 |
related = self.related_boxitems(entity) |
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
173 |
unrelated = self.unrelated_boxitems(entity) |
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
174 |
box.extend(related) |
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
175 |
if related and unrelated: |
0 | 176 |
box.append(BoxSeparator()) |
2757
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
177 |
box.extend(unrelated) |
0 | 178 |
box.render(self.w) |
179 |
||
180 |
def div_id(self): |
|
3451
6b46d73823f5
[api] work in progress, use __regid__, cw_*, etc.
Adrien Di Mascio <Adrien.DiMascio@logilab.fr>
parents:
3230
diff
changeset
|
181 |
return self.__regid__ |
1493 | 182 |
|
0 | 183 |
def box_item(self, entity, etarget, rql, label): |
184 |
"""builds HTML link to edit relation between `entity` and `etarget` |
|
185 |
""" |
|
1149 | 186 |
role, target = get_role(self), get_target(self) |
187 |
args = {role[0] : entity.eid, target[0] : etarget.eid} |
|
4382
6fb02edd05da
3.6 api update, cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4345
diff
changeset
|
188 |
url = self._cw.user_rql_callback((rql, args)) |
0 | 189 |
# for each target, provide a link to edit the relation |
4205
4458c7cc193b
must escape user_rql_callback
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3220
diff
changeset
|
190 |
label = u'[<a href="%s">%s</a>] %s' % (xml_escape(url), label, |
0 | 191 |
etarget.view('incontext')) |
192 |
return RawBoxItem(label, liclass=u'invisible') |
|
1493 | 193 |
|
2757
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
194 |
def related_boxitems(self, entity): |
0 | 195 |
rql = 'DELETE S %s O WHERE S eid %%(s)s, O eid %%(o)s' % self.rtype |
2757
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
196 |
related = [] |
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
197 |
for etarget in self.related_entities(entity): |
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
198 |
related.append(self.box_item(entity, etarget, rql, u'-')) |
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
199 |
return related |
1493 | 200 |
|
2757
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
201 |
def unrelated_boxitems(self, entity): |
0 | 202 |
rql = 'SET S %s O WHERE S eid %%(s)s, O eid %%(o)s' % self.rtype |
2757
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
203 |
unrelated = [] |
0 | 204 |
for etarget in self.unrelated_entities(entity): |
2757
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
205 |
unrelated.append(self.box_item(entity, etarget, rql, u'+')) |
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
206 |
return unrelated |
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
207 |
|
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
208 |
def related_entities(self, entity): |
c8e28e1754f0
B [web.box] fix EditRelationBoxTemplate in case neither related nor unrelated
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
2710
diff
changeset
|
209 |
return entity.related(self.rtype, get_role(self), entities=True) |
0 | 210 |
|
211 |
def unrelated_entities(self, entity): |
|
4385
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
212 |
"""returns the list of unrelated entities, using the entity's |
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
213 |
appropriate vocabulary function |
0 | 214 |
""" |
4385
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
215 |
skip = set(e.eid for e in entity.related(self.rtype, get_role(self), |
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
216 |
entities=True)) |
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
217 |
skip.add(None) |
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
218 |
skip.add(INTERNAL_FIELD_VALUE) |
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
219 |
filteretype = getattr(self, 'etype', None) |
0 | 220 |
entities = [] |
4385
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
221 |
form = self._cw.vreg['forms'].select('edition', self._cw, |
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
222 |
rset=self.cw_rset, |
4382
6fb02edd05da
3.6 api update, cleanup
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4345
diff
changeset
|
223 |
row=self.cw_row or 0) |
1695
9a9822f3cb6c
update implementation to get vocab from form instead of entity
sylvain.thenault@logilab.fr
parents:
1624
diff
changeset
|
224 |
field = form.field_by_name(self.rtype, get_role(self), entity.e_schema) |
4385
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
225 |
for _, eid in field.vocabulary(form): |
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
226 |
if eid not in skip: |
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
227 |
entity = self._cw.entity_from_eid(eid) |
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
228 |
if filteretype is None or entity.__regid__ == filteretype: |
820aa03f71ad
use field.vocabulary instead of field.choices, skip already related eids. Also consider vocabulary when no etype specified
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
4382
diff
changeset
|
229 |
entities.append(entity) |
0 | 230 |
return entities |
1493 | 231 |