Commit 9f170e7c authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

cw 3.6 api updates

parent 05236934a8a3
"""Specific views for baskets
:organization: Logilab
:copyright: 2003-2009 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:copyright: 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: --
__docformat__ = "restructuredtext en"
......@@ -14,14 +14,14 @@ from cubicweb import Unauthorized
from cubicweb.selectors import implements
from cubicweb.web import uicfg, box, action
from cubicweb.web.htmlwidgets import BoxWidget
from cubicweb.web.views import baseviews
from cubicweb.web.views import primary
# displayed by the basket box
uicfg.primaryview_section.tag_subject_of(('*', 'in_basket', '*'), 'hidden')
uicfg.primaryview_section.tag_object_of(('*', 'in_basket', '*'), 'hidden')
class BasketPrimaryView(baseviews.PrimaryView):
class BasketPrimaryView(primary.PrimaryView):
__select__ = implements('Basket',)
entity_name = 'Basket'
nothing_msg = _('nothing in basket')
......@@ -80,12 +80,12 @@ class BasketBox(box.UserRQLBoxTemplate):
def selected_eids(self):
selectedeids = ()
if self.rset:
if self.cw_rset:
# 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._cw.vreg.schema.eschema(etype).is_final():
selectedeids = set(row[0] for row in self.rset.rows)
etype = iter(self.cw_rset.column_types(0)).next()
if not self._cw.vreg.schema.eschema(etype).final:
selectedeids = set(row[0] for row in self.cw_rset.rows)
return selectedeids
def build_inbasket_link(self, box, basket):
......@@ -101,20 +101,21 @@ class BasketBox(box.UserRQLBoxTemplate):
_('add to basket'), xml_escape(
linkto = u'in_basket:%s:object' % '_'.join(addable)
msg = _('selection added to basket')
url = self.build_url('edit', eid=basket.eid, rql=rql,
__linkto=linkto, __message=msg,
__redirectrql=rql, __redirect_vid=vid)
url = self._cw.build_url('edit', eid=basket.eid, rql=rql,
__linkto=linkto, __message=msg,
__redirectrql=rql, __redirect_vid=vid)
box.append(self.mk_action(title, url, category='manage',
def build_delete_link(self, box, basket, inbasketeids, rql, vid):
title = '%s <span class="basketName">%s</span>' % (
_('reset basket'), xml_escape(
delete = '%s:in_basket:%s' % ('_'.join(str(eid) for eid in inbasketeids),
msg = _('Basket %s emptied') %
url = self.build_url('edit', rql=rql, __delete=delete,
__message=msg, __redirectrql=rql,
url = self._cw.build_url('edit', rql=rql, __delete=delete,
__message=msg, __redirectrql=rql,
box.append(self.mk_action(title, url, category='manage'))
def call(self, **kwargs):
......@@ -125,7 +126,7 @@ class BasketBox(box.UserRQLBoxTemplate):
_ = self._cw._
req = self._cw
box = BoxWidget(_(self.title),
box = BoxWidget(_(self.title), self.__regid__)
rschema = self._cw.vreg.schema.rschema(self.rtype)
actions = []
rql = req.form.get('rql') or kwargs.get('rql') or ''
Markdown is supported
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