11 |
11 |
12 from cubicweb import Unauthorized, role as get_role |
12 from cubicweb import Unauthorized, role as get_role |
13 from cubicweb.vregistry import objectify_selector |
13 from cubicweb.vregistry import objectify_selector |
14 from cubicweb.selectors import (one_line_rset, primary_view, |
14 from cubicweb.selectors import (one_line_rset, primary_view, |
15 match_context_prop, has_related_entities, |
15 match_context_prop, has_related_entities, |
16 accepts_compat, condition_compat) |
16 accepts_compat, has_relation_compat, condition_compat) |
17 from cubicweb.common.registerers import accepts_registerer, priority_registerer |
17 from cubicweb.view import Template, ReloadableMixIn |
18 #etype_rtype_selector, has_relation, |
|
19 from cubicweb.common.view import Template, ReloadableMixIn |
|
20 |
18 |
21 from cubicweb.web.htmlwidgets import (BoxLink, BoxWidget, SideBoxWidget, |
19 from cubicweb.web.htmlwidgets import (BoxLink, BoxWidget, SideBoxWidget, |
22 RawBoxItem, BoxSeparator) |
20 RawBoxItem, BoxSeparator) |
23 from cubicweb.web.action import UnregisteredAction |
21 from cubicweb.web.action import UnregisteredAction |
24 |
22 |
101 |
99 |
102 It rely on etype, rtype (both optional, usable to control registration |
100 It rely on etype, rtype (both optional, usable to control registration |
103 according to application schema and display according to connected |
101 according to application schema and display according to connected |
104 user's rights) and rql attributes |
102 user's rights) and rql attributes |
105 """ |
103 """ |
106 __registerer__ = priority_registerer |
|
107 #XXX __selectors__ = BoxTemplate.__selectors__ + (etype_rtype_selector,) |
104 #XXX __selectors__ = BoxTemplate.__selectors__ + (etype_rtype_selector,) |
108 |
105 |
109 rql = None |
106 rql = None |
110 |
107 |
111 def to_display_rql(self): |
108 def to_display_rql(self): |
137 return (self.rql, {'x': self.req.user.eid}, 'x') |
134 return (self.rql, {'x': self.req.user.eid}, 'x') |
138 |
135 |
139 |
136 |
140 class EntityBoxTemplate(BoxTemplate): |
137 class EntityBoxTemplate(BoxTemplate): |
141 """base class for boxes related to a single entity""" |
138 """base class for boxes related to a single entity""" |
142 __registerer__ = accepts_registerer |
|
143 __select__ = one_line_rset() & primary_view() & match_context_prop() |
139 __select__ = one_line_rset() & primary_view() & match_context_prop() |
144 registered = accepts_compat(condition_compat(BoxTemplate.registered)) |
140 registered = accepts_compat(has_relation_compat(condition_compat(BoxTemplate.registered))) |
145 context = 'incontext' |
141 context = 'incontext' |
146 |
142 |
147 def call(self, row=0, col=0, **kwargs): |
143 def call(self, row=0, col=0, **kwargs): |
148 """classes inheriting from EntityBoxTemplate should define cell_call""" |
144 """classes inheriting from EntityBoxTemplate should define cell_call""" |
149 self.cell_call(row, col, **kwargs) |
145 self.cell_call(row, col, **kwargs) |