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

default is now stable

--HG--
branch : stable
...@@ -3,3 +3,5 @@ b331d7df1979ff6e64967b8d9567c998ea64089a cubicweb-basket-version-1_1_0 ...@@ -3,3 +3,5 @@ b331d7df1979ff6e64967b8d9567c998ea64089a cubicweb-basket-version-1_1_0
8c0255d352a3fd5c5adcd7b23f2b908d7c2e8496 cubicweb-basket-version-1_2_0 8c0255d352a3fd5c5adcd7b23f2b908d7c2e8496 cubicweb-basket-version-1_2_0
6f7462ccdcd1e3db8006811bfdbee222e4ab74f1 cubicweb-basket-debian-version-1_2_0-1 6f7462ccdcd1e3db8006811bfdbee222e4ab74f1 cubicweb-basket-debian-version-1_2_0-1
e505819de9bc06118d945436df7be06f3a495b54 oldstable e505819de9bc06118d945436df7be06f3a495b54 oldstable
f82e8285f715dd041cec72685349077a5ec15b8b cubicweb-basket-version-1.3.0
cf16f0ba974e0c292d7b6c87977735e2a81d61db cubicweb-basket-debian-version-1.3.0-1
...@@ -4,25 +4,50 @@ ...@@ -4,25 +4,50 @@
modname = 'basket' modname = 'basket'
distname = "cubicweb-%s" % modname distname = "cubicweb-%s" % modname
numversion = (1, 2, 0) numversion = (1, 3, 0)
version = '.'.join(str(num) for num in numversion) version = '.'.join(str(num) for num in numversion)
license = 'LGPL' license = 'LGPL'
copyright = '''Copyright (c) 2003-2009 LOGILAB S.A. (Paris, FRANCE). copyright = '''Copyright (c) 2003-2010 LOGILAB S.A. (Paris, FRANCE).
http://www.logilab.fr/ -- mailto:contact@logilab.fr''' http://www.logilab.fr/ -- mailto:contact@logilab.fr'''
author = "Logilab" author = "Logilab"
author_email = "contact@logilab.fr" author_email = "contact@logilab.fr"
web = 'http://www.cubicweb.org/project/%s' % distname web = 'http://www.cubicweb.org/project/%s' % distname
short_desc = "basket component for the Cubicweb framework" short_desc = "shopping cart component for the CubicWeb framework"
long_desc = """This Cubicweb component provides baskets as a way to select content. long_desc = """\
Summary
-------
This cube provides a shopping cart functionality.
Usage
-----
By default, any entity can be added to a basket (this uses the
`in_basket` relation).
There is a box that displays all items in the basket. By default, this
box is hidden. To display it, add in a view this code:
.. sourcecode:: python
from cubes.basket.views import BasketBox
BasketBox.visible = True
CubicWeb is a semantic web application framework, see http://www.cubicweb.org
""" """
classifiers = [
'Environment :: Web Environment',
'Framework :: CubicWeb',
'Programming Language :: Python',
'Programming Language :: JavaScript',
]
__depends_cubes__ = {} __depends_cubes__ = {}
__depends__ = {'cubicweb': '>= 3.2.0'} __depends__ = {'cubicweb': '>= 3.6.0'}
__use__ = () __use__ = ()
# packaging ### # packaging ###
......
cubicweb-basket (1.3.0-1) unstable; urgency=low
* new upstream release
-- Sylvain Thénault <sylvain.thenault@logilab.fr> Wed, 27 Jan 2010 11:59:57 +0100
cubicweb-basket (1.2.0-1) unstable; urgency=low cubicweb-basket (1.2.0-1) unstable; urgency=low
* new upstream release depending on cubicweb 3.2 * new upstream release depending on cubicweb 3.2
......
...@@ -8,7 +8,7 @@ Standards-Version: 3.8.0 ...@@ -8,7 +8,7 @@ Standards-Version: 3.8.0
Package: cubicweb-basket Package: cubicweb-basket
Architecture: all Architecture: all
Depends: cubicweb-common (>= 3.2.0) Depends: cubicweb-common (>= 3.6.0)
Description: basket component for the Cubicweb framework Description: basket component for the Cubicweb framework
This Cubicweb component provides baskets as a way to select content. This Cubicweb component provides baskets as a way to select content.
. .
......
...@@ -41,9 +41,6 @@ msgstr "select basket content" ...@@ -41,9 +41,6 @@ msgstr "select basket content"
msgid "actions_select_basket_content_description" msgid "actions_select_basket_content_description"
msgstr "" msgstr ""
msgid "add a Basket"
msgstr ""
msgid "add to basket" msgid "add to basket"
msgstr "" msgstr ""
...@@ -59,21 +56,128 @@ msgstr "box to handle baskets" ...@@ -59,21 +56,128 @@ msgstr "box to handle baskets"
msgid "create basket" msgid "create basket"
msgstr "" msgstr ""
# subject and object forms for each relation type
# (no object form for final or symetric relation types)
msgctxt "Basket"
msgid "description"
msgstr ""
msgctxt "Basket"
msgid "description_format"
msgstr "format"
# subject and object forms for each relation type # subject and object forms for each relation type
# (no object form for final relation types) # (no object form for final relation types)
msgid "in_basket" msgid "in_basket"
msgstr "in basket" msgstr "in basket"
msgctxt "CWRelation"
msgid "in_basket"
msgstr ""
msgctxt "Bookmark"
msgid "in_basket"
msgstr ""
msgctxt "CWAttribute"
msgid "in_basket"
msgstr ""
msgctxt "CWConstraintType"
msgid "in_basket"
msgstr ""
msgctxt "RQLExpression"
msgid "in_basket"
msgstr ""
msgctxt "BaseTransition"
msgid "in_basket"
msgstr ""
msgctxt "CWEType"
msgid "in_basket"
msgstr ""
msgctxt "Workflow"
msgid "in_basket"
msgstr ""
msgctxt "CWGroup"
msgid "in_basket"
msgstr ""
msgctxt "TrInfo"
msgid "in_basket"
msgstr ""
msgctxt "CWProperty"
msgid "in_basket"
msgstr ""
msgctxt "CWUser"
msgid "in_basket"
msgstr ""
msgctxt "Transition"
msgid "in_basket"
msgstr ""
msgctxt "CWRType"
msgid "in_basket"
msgstr ""
msgctxt "Basket"
msgid "in_basket"
msgstr ""
msgctxt "SubWorkflowExitPoint"
msgid "in_basket"
msgstr ""
msgctxt "ExternalUri"
msgid "in_basket"
msgstr ""
msgctxt "CWCache"
msgid "in_basket"
msgstr ""
msgctxt "WorkflowTransition"
msgid "in_basket"
msgstr ""
msgctxt "State"
msgid "in_basket"
msgstr ""
msgctxt "CWPermission"
msgid "in_basket"
msgstr ""
msgctxt "EmailAddress"
msgid "in_basket"
msgstr ""
msgctxt "CWConstraint"
msgid "in_basket"
msgstr ""
msgctxt "Basket"
msgid "in_basket_object"
msgstr ""
msgid "in_basket_object" msgid "in_basket_object"
msgstr "contains" msgstr "contains"
msgid "items in this basket" msgid "items in this basket"
msgstr "" msgstr ""
msgid "nothing in basket" msgctxt "Basket"
msgstr "" msgid "name"
msgstr "name"
msgid "remove this Basket" msgid "nothing in basket"
msgstr "" msgstr ""
msgid "reset basket" msgid "reset basket"
......
...@@ -41,9 +41,6 @@ msgstr "séléctionner le contenu du panier" ...@@ -41,9 +41,6 @@ msgstr "séléctionner le contenu du panier"
msgid "actions_select_basket_content_description" msgid "actions_select_basket_content_description"
msgstr "" msgstr ""
msgid "add a Basket"
msgstr "ajouter un panier"
msgid "add to basket" msgid "add to basket"
msgstr "ajouter au panier" msgstr "ajouter au panier"
...@@ -59,23 +56,130 @@ msgstr "boîte de gestion de paniers" ...@@ -59,23 +56,130 @@ msgstr "boîte de gestion de paniers"
msgid "create basket" msgid "create basket"
msgstr "créer un panier" msgstr "créer un panier"
# subject and object forms for each relation type
# (no object form for final or symetric relation types)
msgctxt "Basket"
msgid "description"
msgstr "description"
msgctxt "Basket"
msgid "description_format"
msgstr "format"
# subject and object forms for each relation type # subject and object forms for each relation type
# (no object form for final relation types) # (no object form for final relation types)
msgid "in_basket" msgid "in_basket"
msgstr "dans le panier" msgstr "dans le panier"
msgctxt "CWRelation"
msgid "in_basket"
msgstr "dans le panier"
msgctxt "Bookmark"
msgid "in_basket"
msgstr ""
msgctxt "CWAttribute"
msgid "in_basket"
msgstr ""
msgctxt "CWConstraintType"
msgid "in_basket"
msgstr ""
msgctxt "RQLExpression"
msgid "in_basket"
msgstr ""
msgctxt "BaseTransition"
msgid "in_basket"
msgstr ""
msgctxt "CWEType"
msgid "in_basket"
msgstr ""
msgctxt "Workflow"
msgid "in_basket"
msgstr ""
msgctxt "CWGroup"
msgid "in_basket"
msgstr ""
msgctxt "TrInfo"
msgid "in_basket"
msgstr ""
msgctxt "CWProperty"
msgid "in_basket"
msgstr ""
msgctxt "CWUser"
msgid "in_basket"
msgstr ""
msgctxt "Transition"
msgid "in_basket"
msgstr ""
msgctxt "CWRType"
msgid "in_basket"
msgstr ""
msgctxt "Basket"
msgid "in_basket"
msgstr ""
msgctxt "SubWorkflowExitPoint"
msgid "in_basket"
msgstr ""
msgctxt "ExternalUri"
msgid "in_basket"
msgstr ""
msgctxt "CWCache"
msgid "in_basket"
msgstr ""
msgctxt "WorkflowTransition"
msgid "in_basket"
msgstr ""
msgctxt "State"
msgid "in_basket"
msgstr ""
msgctxt "CWPermission"
msgid "in_basket"
msgstr ""
msgctxt "EmailAddress"
msgid "in_basket"
msgstr ""
msgctxt "CWConstraint"
msgid "in_basket"
msgstr ""
msgctxt "Basket"
msgid "in_basket_object"
msgstr ""
msgid "in_basket_object" msgid "in_basket_object"
msgstr "contenu par" msgstr "contenu par"
msgid "items in this basket" msgid "items in this basket"
msgstr "entités dans ce panier" msgstr "entités dans ce panier"
msgctxt "Basket"
msgid "name"
msgstr "nom"
msgid "nothing in basket" msgid "nothing in basket"
msgstr "panier vide" msgstr "panier vide"
msgid "remove this Basket"
msgstr "supprimer ce panier"
msgid "reset basket" msgid "reset basket"
msgstr "vider le panier" msgstr "vider le panier"
......
from cubicweb.schema import format_constraint from yams.buildobjs import EntityType, RelationType, ObjectRelation, String
try:
from yams.buildobjs import RichString
except ImportError:
from cubicweb.schema import RichString
class Basket(MetaUserEntityType): from cubicweb.schema import ERQLExpression
class Basket(EntityType):
"""a basket contains a set of other entities""" """a basket contains a set of other entities"""
permissions = { __permissions__ = {
'read': ('managers', ERQLExpression('X owned_by U'),), 'read': ('managers', ERQLExpression('X owned_by U'),),
'add': ('managers', 'users',), 'add': ('managers', 'users',),
'delete': ('managers', 'owners',), 'delete': ('managers', 'owners',),
...@@ -11,12 +17,10 @@ class Basket(MetaUserEntityType): ...@@ -11,12 +17,10 @@ class Basket(MetaUserEntityType):
name = String(required=True, indexed=True, internationalizable=True, name = String(required=True, indexed=True, internationalizable=True,
maxsize=128) maxsize=128)
description_format = String(meta=True, internationalizable=True, maxsize=50, description = RichString(fulltextindexed=True)
default='text/rest', constraints=[format_constraint])
description = String(fulltextindexed=True)
in_basket = ObjectRelation('*') in_basket = ObjectRelation('*')
class in_basket(MetaUserRelationType): class in_basket(RelationType):
pass pass
from logilab.common.testlib import TestCase, unittest_main from logilab.common.testlib import TestCase, unittest_main
class BasketTC(TestCase):
def test_something(self):
self.skip('this component has no test')
if __name__ == '__main__': if __name__ == '__main__':
unittest_main() unittest_main()
"""Specific views for baskets """Specific views for baskets
:organization: Logilab :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: http://www.logilab.fr/ -- mailto:contact@logilab.fr :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
""" """
__docformat__ = "restructuredtext en" __docformat__ = "restructuredtext en"
_ = unicode _ = unicode
from logilab.mtconverter import html_escape from logilab.mtconverter import xml_escape
from cubicweb import Unauthorized from cubicweb import Unauthorized
from cubicweb.selectors import implements from cubicweb.selectors import implements
from cubicweb.web import uicfg, box, action from cubicweb.web import uicfg, box, action
from cubicweb.web.htmlwidgets import BoxWidget from cubicweb.web.htmlwidgets import BoxWidget
from cubicweb.web.views import baseviews from cubicweb.web.views import primary
# displayed by the basket box # displayed by the basket box
uicfg.primaryview_section.tag_subject_of(('*', 'in_basket', '*'), 'hidden') uicfg.primaryview_section.tag_subject_of(('*', 'in_basket', '*'), 'hidden')
uicfg.primaryview_section.tag_object_of(('*', 'in_basket', '*'), 'hidden') uicfg.primaryview_section.tag_object_of(('*', 'in_basket', '*'), 'hidden')
class BasketPrimaryView(baseviews.PrimaryView): class BasketPrimaryView(primary.PrimaryView):
__select__ = implements('Basket',) __select__ = implements('Basket',)
entity_name = 'Basket' entity_name = 'Basket'
nothing_msg = _('nothing in basket') nothing_msg = _('nothing in basket')
...@@ -29,19 +29,19 @@ class BasketPrimaryView(baseviews.PrimaryView): ...@@ -29,19 +29,19 @@ class BasketPrimaryView(baseviews.PrimaryView):
def display_title(self, entity): def display_title(self, entity):
self.w(u"<span class='title'><b>%s : %s</b></span>" % ( 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), xml_escape(entity.name)))
def display_content(self, entity): 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') {'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: if rset:
self.wview('list', rset) self.wview('list', rset)
else: else:
self.w(self.req._(self.nothing_msg)) self.w(self._cw._(self.nothing_msg))
def cell_call(self, row, col): 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.w(u'&nbsp;')
self.display_title(entity) self.display_title(entity)
if entity.description: if entity.description:
...@@ -69,7 +69,7 @@ def insert_eids(actions, eids): ...@@ -69,7 +69,7 @@ def insert_eids(actions, eids):
class BasketBox(box.UserRQLBoxTemplate): class BasketBox(box.UserRQLBoxTemplate):
"""display a box containing all user's basketitems""" """display a box containing all user's basketitems"""
id = 'basket_box' __regid__ = 'basket_box'
visible = False # disabled by default visible = False # disabled by default
order = 30 order = 30
title = _('basket') title = _('basket')
...@@ -80,53 +80,54 @@ class BasketBox(box.UserRQLBoxTemplate): ...@@ -80,53 +80,54 @@ class BasketBox(box.UserRQLBoxTemplate):
def selected_eids(self): def selected_eids(self):
selectedeids = () selectedeids = ()
if self.rset: if self.cw_rset:
# something is being displayed. If the first column contains eids, # something is being displayed. If the first column contains eids,
# fetch them so we can propose to add the selection to the basket # fetch them so we can propose to add the selection to the basket
etype = iter(self.rset.column_types(0)).next() etype = iter(self.cw_rset.column_types(0)).next()
if not self.schema.eschema(etype).is_final(): if not self._cw.vreg.schema.eschema(etype).final:
selectedeids = set(row[0] for row in self.rset.rows) selectedeids = set(row[0] for row in self.cw_rset.rows)
return selectedeids return selectedeids
def build_inbasket_link(self, box, basket): def build_inbasket_link(self, box, basket):
rset = basket.related('in_basket', 'object') rset = basket.related('in_basket', 'object')
title = u'%s <span class="basketName">%s</span> (%s)' % ( title = u'%s <span class="basketName">%s</span> (%s)' % (
_('view basket'), html_escape(basket.name), len(rset)) _('view basket'), xml_escape(basket.name), len(rset))
box.append(self.mk_action(title, basket.absolute_url(), box.append(self.mk_action(title, basket.absolute_url(),
escape=False)) escape=False))
return rset, [row[0] for row in rset] return rset, [row[0] for row in rset]
def build_add_link(self, box, basket, addable, rql, vid): def build_add_link(self, box, basket, addable, rql, vid):
title = u'%s <span class="basketName">%s</span>' % ( title = u'%s <span class="basketName">%s</span>' % (
_('add to basket'), html_escape(basket.name)) _('add to basket'), xml_escape(basket.name))
linkto = u'in_basket:%s:object' % '_'.join(addable) linkto = u'in_basket:%s:object' % '_'.join(addable)
msg = _('selection added to basket') msg = _('selection added to basket')
url = self.build_url('edit', eid=basket.eid, rql=rql, url = self._cw.build_url('edit', eid=basket.eid, rql=rql,
__linkto=linkto, __message=msg, __linkto=linkto, __message=msg,
__redirectrql=rql, __redirect_vid=vid) __redirectrql=rql, __redirect_vid=vid)
box.append(self.mk_action(title, url, category='manage', box.append(self.mk_action(title, url, category='manage',
escape=False)) escape=False))
def build_delete_link(self, box, basket, inbasketeids, rql, vid): def build_delete_link(self, box, basket, inbasketeids, rql, vid):
title = '%s <span class="basketName">%s</span>' % ( title = '%s <span class="basketName">%s</span>' % (
_('reset basket'), html_escape(basket.name)) _('reset basket'), xml_escape(basket.name))
delete = '%s:in_basket:%s' % ('_'.join(str(eid) for eid in inbasketeids), delete = '%s:in_basket:%s' % ('_'.join(str(eid) for eid in inbasketeids),
basket.eid) basket.eid)
msg = _('Basket %s emptied') % basket.name msg = _('Basket %s emptied') % basket.name
url = self.build_url('edit', rql=rql, __delete=delete,