Commit 5c41c775 authored by Sandrine Ribeau's avatar Sandrine Ribeau
Browse files

cw 3.6 api update

parent b146fb0e55c3
......@@ -8,7 +8,7 @@ from cubicweb.schema import ERQLExpression
class Basket(EntityType):
"""a basket contains a set of other entities"""
permissions = {
__permissions__ = {
'read': ('managers', ERQLExpression('X owned_by U'),),
'add': ('managers', 'users',),
'delete': ('managers', 'owners',),
......
......@@ -29,19 +29,19 @@ class BasketPrimaryView(baseviews.PrimaryView):
def display_title(self, entity):
self.w(u"<span class='title'><b>%s : %s</b></span>" % (
self.req._(self.entity_name), html_escape(entity.name)))
self._cw._(self.entity_name), html_escape(entity.name)))
def display_content(self, entity):
rset = self.req.execute('Any I WHERE I in_basket B, B eid %(x)s',
rset = self._cw.execute('Any I WHERE I in_basket B, B eid %(x)s',
{'x': entity.eid}, 'x')
self.w('<h5>%s</h5>' % self.req._(self.content_msg))
self.w('<h5>%s</h5>' % self._cw._(self.content_msg))
if rset:
self.wview('list', rset)
else:
self.w(self.req._(self.nothing_msg))
self.w(self._cw._(self.nothing_msg))
def cell_call(self, row, col):
entity = self.complete_entity(row, col)
entity = self.cw_rset.complete_entity(row, col)
self.w(u'&nbsp;')
self.display_title(entity)
if entity.description:
......@@ -69,7 +69,7 @@ def insert_eids(actions, eids):
class BasketBox(box.UserRQLBoxTemplate):
"""display a box containing all user's basketitems"""
id = 'basket_box'
__regid__ = 'basket_box'
visible = False # disabled by default
order = 30
title = _('basket')
......@@ -84,7 +84,7 @@ class BasketBox(box.UserRQLBoxTemplate):
# something is being displayed. If the first column contains eids,
# fetch them so we can propose to add the selection to the basket
etype = iter(self.rset.column_types(0)).next()
if not self.schema.eschema(etype).is_final():
if not self._cw.vreg.schema.eschema(etype).is_final():
selectedeids = set(row[0] for row in self.rset.rows)
return selectedeids
......@@ -119,14 +119,14 @@ class BasketBox(box.UserRQLBoxTemplate):
def call(self, **kwargs):
try:
baskets = self.req.execute(*self.to_display_rql())
baskets = self._cw.execute(*self.to_display_rql())
except Unauthorized:
# can't access to something in the query, forget this box
return
_ = self.req._
req = self.req
_ = self._cw._
req = self._cw
box = BoxWidget(_(self.title), self.id)
rschema = self.schema.rschema(self.rtype)
rschema = self._cw.vreg.schema.rschema(self.rtype)
actions = []
rql = req.form.get('rql') or kwargs.get('rql') or ''
vid = req.form.get('vid', '')
......@@ -142,7 +142,7 @@ class BasketBox(box.UserRQLBoxTemplate):
continue
if rschema.has_perm(req, 'delete'):
self.build_delete_link(box, basket, inbasketeids, rql, vid)
eschema = self.schema.eschema(self.etype)
eschema = self._cw.vreg.schema.eschema(self.etype)
if eschema.has_perm(req, 'add'):
actions.append(self.mk_action(_('create basket'),
self.create_url(self.etype),
......@@ -155,11 +155,11 @@ class SelectBasketContentAction(action.Action):
category = 'mainactions'
__select__ = implements('Basket')
id = 'select_basket_content'
__regid__ = 'select_basket_content'
title = _('actions_select_basket_content')
def url(self):
rql = u'Any X WHERE X in_basket B, B eid %s' % self.rset[self.row or 0][self.col or 0]
return self.build_url(rql=rql)
rql = u'Any X WHERE X in_basket B, B eid %s' % self.cw_rset[self.cw_row or 0][self.cw_col or 0]
return self._cw.build_url(rql=rql)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment