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
8c0255d352a3fd5c5adcd7b23f2b908d7c2e8496 cubicweb-basket-version-1_2_0
6f7462ccdcd1e3db8006811bfdbee222e4ab74f1 cubicweb-basket-debian-version-1_2_0-1
e505819de9bc06118d945436df7be06f3a495b54 oldstable
f82e8285f715dd041cec72685349077a5ec15b8b cubicweb-basket-version-1.3.0
cf16f0ba974e0c292d7b6c87977735e2a81d61db cubicweb-basket-debian-version-1.3.0-1
......@@ -4,25 +4,50 @@
modname = 'basket'
distname = "cubicweb-%s" % modname
numversion = (1, 2, 0)
numversion = (1, 3, 0)
version = '.'.join(str(num) for num in numversion)
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'''
author = "Logilab"
author_email = "contact@logilab.fr"
web = 'http://www.cubicweb.org/project/%s' % distname
short_desc = "basket component for the Cubicweb framework"
long_desc = """This Cubicweb component provides baskets as a way to select content.
short_desc = "shopping cart component for the CubicWeb framework"
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__ = {'cubicweb': '>= 3.2.0'}
__depends__ = {'cubicweb': '>= 3.6.0'}
__use__ = ()
# 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
* new upstream release depending on cubicweb 3.2
......
......@@ -8,7 +8,7 @@ Standards-Version: 3.8.0
Package: cubicweb-basket
Architecture: all
Depends: cubicweb-common (>= 3.2.0)
Depends: cubicweb-common (>= 3.6.0)
Description: basket component for the Cubicweb framework
This Cubicweb component provides baskets as a way to select content.
.
......
......@@ -41,9 +41,6 @@ msgstr "select basket content"
msgid "actions_select_basket_content_description"
msgstr ""
msgid "add a Basket"
msgstr ""
msgid "add to basket"
msgstr ""
......@@ -59,21 +56,128 @@ msgstr "box to handle baskets"
msgid "create basket"
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
# (no object form for final relation types)
msgid "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"
msgstr "contains"
msgid "items in this basket"
msgstr ""
msgid "nothing in basket"
msgstr ""
msgctxt "Basket"
msgid "name"
msgstr "name"
msgid "remove this Basket"
msgid "nothing in basket"
msgstr ""
msgid "reset basket"
......
......@@ -41,9 +41,6 @@ msgstr "séléctionner le contenu du panier"
msgid "actions_select_basket_content_description"
msgstr ""
msgid "add a Basket"
msgstr "ajouter un panier"
msgid "add to basket"
msgstr "ajouter au panier"
......@@ -59,23 +56,130 @@ msgstr "boîte de gestion de paniers"
msgid "create basket"
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
# (no object form for final relation types)
msgid "in_basket"
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"
msgstr "contenu par"
msgid "items in this basket"
msgstr "entités dans ce panier"
msgctxt "Basket"
msgid "name"
msgstr "nom"
msgid "nothing in basket"
msgstr "panier vide"
msgid "remove this Basket"
msgstr "supprimer ce panier"
msgid "reset basket"
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"""
permissions = {
__permissions__ = {
'read': ('managers', ERQLExpression('X owned_by U'),),
'add': ('managers', 'users',),
'delete': ('managers', 'owners',),
......@@ -11,12 +17,10 @@ class Basket(MetaUserEntityType):
name = String(required=True, indexed=True, internationalizable=True,
maxsize=128)
description_format = String(meta=True, internationalizable=True, maxsize=50,
default='text/rest', constraints=[format_constraint])
description = String(fulltextindexed=True)
description = RichString(fulltextindexed=True)
in_basket = ObjectRelation('*')
class in_basket(MetaUserRelationType):
class in_basket(RelationType):
pass
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__':
unittest_main()
"""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: http://www.logilab.fr/ -- mailto:contact@logilab.fr
"""
__docformat__ = "restructuredtext en"
_ = unicode
from logilab.mtconverter import html_escape
from logilab.mtconverter import xml_escape
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')
......@@ -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), xml_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')
......@@ -80,53 +80,54 @@ 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.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):
rset = basket.related('in_basket', 'object')
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(),
escape=False))
return rset, [row[0] for row in rset]
def build_add_link(self, box, basket, addable, rql, vid):
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)
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',
escape=False))
def build_delete_link(self, box, basket, inbasketeids, rql, vid):
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),
basket.eid)
msg = _('Basket %s emptied') % basket.name
url = self.build_url('edit', rql=rql, __delete=delete,
__message=msg, __redirectrql=rql,
__redirect_vid=vid)
url = self._cw.build_url('edit', rql=rql, __delete=delete,
__message=msg, __redirectrql=rql,
__redirect_vid=vid)
box.append(self.mk_action(title, url, category='manage'))
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
box = BoxWidget(_(self.title), self.id)
rschema = self.schema.rschema(self.rtype)
_ = self._cw._
req = self._cw
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 ''
vid = req.form.get('vid', '')
......@@ -142,7 +143,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 +156,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)
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