4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
4 :copyright: 2001-2009 LOGILAB S.A. (Paris, FRANCE), license is LGPL v2. |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
5 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
6 :license: GNU Lesser General Public License, v2.1 - http://www.gnu.org/licenses |
7 """ |
7 """ |
8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
|
9 _ = unicode |
9 |
10 |
10 from logilab.mtconverter import html_escape |
11 from logilab.mtconverter import html_escape |
11 |
12 |
12 from cubicweb import Unauthorized, role as get_role, target as get_target |
13 from cubicweb import Unauthorized, role as get_role, target as get_target |
13 from cubicweb.selectors import (one_line_rset, primary_view, |
14 from cubicweb.selectors import (one_line_rset, primary_view, |
17 from cubicweb.view import View, ReloadableMixIn |
18 from cubicweb.view import View, ReloadableMixIn |
18 |
19 |
19 from cubicweb.web.htmlwidgets import (BoxLink, BoxWidget, SideBoxWidget, |
20 from cubicweb.web.htmlwidgets import (BoxLink, BoxWidget, SideBoxWidget, |
20 RawBoxItem, BoxSeparator) |
21 RawBoxItem, BoxSeparator) |
21 from cubicweb.web.action import UnregisteredAction |
22 from cubicweb.web.action import UnregisteredAction |
22 |
|
23 _ = unicode |
|
24 |
23 |
25 |
24 |
26 class BoxTemplate(View): |
25 class BoxTemplate(View): |
27 """base template for boxes, usually a (contextual) list of possible |
26 """base template for boxes, usually a (contextual) list of possible |
28 |
27 |
218 # use entity.unrelated if we've been asked for a particular etype |
217 # use entity.unrelated if we've been asked for a particular etype |
219 if hasattr(self, 'etype'): |
218 if hasattr(self, 'etype'): |
220 return entity.unrelated(self.rtype, self.etype, get_role(self)).entities() |
219 return entity.unrelated(self.rtype, self.etype, get_role(self)).entities() |
221 # in other cases, use vocabulary functions |
220 # in other cases, use vocabulary functions |
222 entities = [] |
221 entities = [] |
223 form = self.vreg.select_object('forms', 'edition', self.req, self.rset, |
222 form = self.vreg.select('forms', 'edition', self.req, rset=self.rset, |
224 row=self.row or 0) |
223 row=self.row or 0) |
225 field = form.field_by_name(self.rtype, get_role(self), entity.e_schema) |
224 field = form.field_by_name(self.rtype, get_role(self), entity.e_schema) |
226 for _, eid in form.form_field_vocabulary(field): |
225 for _, eid in form.form_field_vocabulary(field): |
227 if eid is not None: |
226 if eid is not None: |
228 rset = self.req.eid_rset(eid) |
227 rset = self.req.eid_rset(eid) |
229 entities.append(rset.get_entity(0, 0)) |
228 entities.append(rset.get_entity(0, 0)) |