diff --git a/commerce/README.txt b/commerce/README.txt index 7199863..9232e57 100644 --- a/commerce/README.txt +++ b/commerce/README.txt @@ -1,14 +1,41 @@ -========================================== -Commerce: Products, Customers, Orders, ... -========================================== +================================================= +Commerce: Shope, Products, Customers, Orders, ... +================================================= ($Id$) -Products -======== +Shops and Products +================== -Let's start with a Product: +Let's start with a Shop: + + >>> from cybertools.commerce.base import Shop + >>> shop1 = Shop(u'shop1', u'PC up Ltd') + +Now we add products to the shop. >>> from cybertools.commerce.product import Product - >>> p1 = Product() + >>> p001 = Product(u'p001', u'Silent Case') + + >>> shop1.addProduct(p001) + + >>> sorted((name, p.title) for name, p in shop1.products.items()) + [(u'p001', u'Silent Case')] + +Let's have a look at the product - it should correctly reference the shop +it belongs to. + + >>> len(p001.shops) + 1 + >>> p001.shops.keys()[0] + u'shop1' + + +Customers +========= + + +Orders +====== + diff --git a/commerce/base.py b/commerce/base.py new file mode 100644 index 0000000..08ee9d7 --- /dev/null +++ b/commerce/base.py @@ -0,0 +1,44 @@ +# +# Copyright (c) 2008 Helmut Merz helmutm@cy55.de +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +""" +Base classes. + +$Id$ +""" + +from zope.interface import implements, Interface + +from cybertools.commerce.interfaces import IShop + + +class Shop(object): + + implements(IShop) + + title = u'Shop' + + def __init__(self, name, title=None): + self.name = name + if title is not None: + self.title = title + self.products = {} + + def addProduct(self, product): + self.products[product.name] = product + product.shops[self.name] = self diff --git a/commerce/interfaces.py b/commerce/interfaces.py index af446f0..0c10c46 100644 --- a/commerce/interfaces.py +++ b/commerce/interfaces.py @@ -61,6 +61,10 @@ class IShop(Interface): u'this shop.') customers = Attribute(u'The customers registered for this shop.') + def addProduct(product): + """ Add the product given to the shop's product listing. + """ + # suppliers @@ -98,8 +102,7 @@ class IProduct(Interface): productId = schema.ASCIILine( title=_(u'Product Identifier'), - description=_(u'A name or number uniquely identifiying the ' - u'product within a shop.'), + description=_(u'A name or number uniquely identifiying the product.'), default='', required=True) title = schema.TextLine( diff --git a/commerce/locales/de/LC_MESSAGES/cybertools.commerce.mo b/commerce/locales/de/LC_MESSAGES/cybertools.commerce.mo index bbbb2e1..d2d8e7d 100644 Binary files a/commerce/locales/de/LC_MESSAGES/cybertools.commerce.mo and b/commerce/locales/de/LC_MESSAGES/cybertools.commerce.mo differ diff --git a/commerce/locales/de/LC_MESSAGES/cybertools.commerce.po b/commerce/locales/de/LC_MESSAGES/cybertools.commerce.po index 1a46387..9bdbf36 100644 --- a/commerce/locales/de/LC_MESSAGES/cybertools.commerce.po +++ b/commerce/locales/de/LC_MESSAGES/cybertools.commerce.po @@ -17,8 +17,8 @@ msgstr "Artikel" msgid "Product Identifier" msgstr "Artikelnummer" -msgid "A name or number uniquely identifiying the product within a shop." -msgstr "Kurzbezeichnung oder Nummer, die den Artikel innerhalb eines Shops eindeutig identifiziert." +msgid "A name or number uniquely identifiying the product." +msgstr "Kurzbezeichnung oder Nummer, die den Artikel eindeutig identifiziert." msgid "Product Name" msgstr "Artikelbezeichnung" diff --git a/commerce/product.py b/commerce/product.py index 24458f0..cfa8a5c 100644 --- a/commerce/product.py +++ b/commerce/product.py @@ -31,3 +31,11 @@ class Product(object): implements(IProduct) + title = u'Product' + + def __init__(self, name, title=None): + self.name = name + if title is not None: + self.title = title + self.shops = {} + diff --git a/commerce/tests.py b/commerce/tests.py index 7496228..85ce6d1 100755 --- a/commerce/tests.py +++ b/commerce/tests.py @@ -14,7 +14,7 @@ class Test(unittest.TestCase): "Basic tests." def testBasicStuff(self): - p = Product() + p = Product('p001') def test_suite():