Changeset 12343


Ignore:
Timestamp:
30 Dec 2014, 12:52:40 (10 years ago)
Author:
Henrik Bettermann
Message:

Move ProductOption? interfaces to productoptions to avoid nasty circular imports.

Use ISO_4217_CURRENCIES.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12342 r12343  
    12931293        # from the chosen product.
    12941294        self.assertTrue('<option selected="selected" value="Any product option">'
    1295                         'Any product option @ 88.8 EUR</option>'
     1295                        'Any product option @ 88.8 Euro</option>'
    12961296                        in self.browser.contents)
    12971297        self.assertTrue('<option value="First option">First option '
    1298                         '@ 99.9 USD</option>' in self.browser.contents)
     1298                        '@ 99.9 US Dollar</option>' in self.browser.contents)
    12991299        # In test browser we can at least replace the option
    13001300        self.browser.getControl(
     
    13041304        self.assertEqual(contract.product_options[0].title, 'First option')
    13051305        self.browser.getLink("View").click()
    1306         self.assertTrue('<span>First option @ 99.9 USD</span>' in self.browser.contents)
     1306        self.assertTrue('<span>First option @ 99.9 US Dollar</span>' in self.browser.contents)
    13071307        self.assertEqual(self.browser.url, self.contracts_path + '/%s/index' % conid)
    13081308        # An href attribute is referring to the document and product objects
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/vocabularies.py

    r12340 r12343  
    3333from waeup.ikoba.utils.helpers import get_sorted_preferred
    3434from waeup.ikoba.utils.countries import COUNTRIES
     35from waeup.ikoba.payments.currencies import ISO_4217_CURRENCIES
    3536
    3637#: a tuple of tuples (<COUNTRY-NAME>, <ISO-CODE>) with Nigeria first.
     
    203204
    204205    def getTitle(self, context, value):
    205         return "%s @ %s %s" % (value.title, value.fee, value.currency)
     206        currency = ISO_4217_CURRENCIES[value.currency][1]
     207        return "%s @ %s %s" % (value.title, value.fee, currency)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/interfaces.py

    r12342 r12343  
    8686            SimpleTerm(value, value, title) for title, value in terms])
    8787
    88 currencies = SimpleIkobaVocabulary(
    89     (_('NGN'),'NGN'),
    90     (_('USD'),'USD'),
    91     (_('EUR'),'EUR'),
    92     )
    93 
    9488class ContextualDictSourceFactoryBase(SmartBasicContextualSourceFactory):
    9589    """A base for contextual sources based on IkobaUtils dicts.
     
    211205        return value
    212206
    213 # We have to keep the following two classes here. In products.interfaces they
    214 # will cause circular imports.
    215 class IProductOption(Interface):
    216     """A product option entry.
    217 
    218     """
    219     title = schema.TextLine(
    220         title = _(u'Title'),
    221         required = True,
    222         )
    223     fee = schema.Decimal(
    224         title = _(u'Fee'),
    225         required = False,
    226         )
    227     currency = schema.Choice(
    228         title = _(u'Currency'),
    229         vocabulary = currencies,
    230         required = False,
    231         )
    232 
    233 class IProductOptionField(IObject):
    234     """A zope.schema-like field for usage in interfaces.
    235 
    236     Marker interface to distuingish product options from ordinary
    237     object fields. Needed for registration of widgets.
    238     """
    239 
    240207class IIkobaUtils(Interface):
    241208    """A collection of methods which are subject to customization.
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/productoptions.py

    r12331 r12343  
    1616## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
    1717##
    18 """Components representing and aggregating product options.
     18"""Components with interfaces representing and aggregating product options.
    1919"""
    2020import grok
    2121from decimal import Decimal
     22from zope import schema
     23from zope.schema.interfaces import IObject
     24from zope.interface import Attribute, Interface
    2225from zope.formlib.interfaces import IInputWidget, IDisplayWidget
    2326from zope.publisher.interfaces.browser import IBrowserRequest
    2427from zope.schema.fieldproperty import FieldProperty
    2528from zope.schema import Object
    26 from waeup.ikoba.interfaces import IProductOption, IProductOptionField
     29from waeup.ikoba.interfaces import SimpleIkobaVocabulary
     30from waeup.ikoba.interfaces import MessageFactory as _
    2731from waeup.ikoba.widgets.objectwidget import (
    2832    IkobaObjectWidget, IkobaObjectDisplayWidget
    2933    )
     34from waeup.ikoba.payments.currencies import ISO_4217_CURRENCIES_VOCAB as currencies
     35
     36#currencies = SimpleIkobaVocabulary(
     37#    (_('NGN'),'NGN'),
     38#    (_('USD'),'USD'),
     39#    (_('EUR'),'EUR'),
     40#    )
     41
     42class IProductOption(Interface):
     43    """A product option entry.
     44
     45    """
     46    title = schema.TextLine(
     47        title = _(u'Title'),
     48        required = True,
     49        )
     50    fee = schema.Decimal(
     51        title = _(u'Fee'),
     52        required = False,
     53        )
     54    currency = schema.Choice(
     55        title = _(u'Currency'),
     56        vocabulary = currencies,
     57        required = False,
     58        )
     59
     60class IProductOptionField(IObject):
     61    """A zope.schema-like field for usage in interfaces.
     62
     63    Marker interface to distuingish product options from ordinary
     64    object fields. Needed for registration of widgets.
     65    """
    3066
    3167class ProductOption(grok.Model):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_productoptions.py

    r12342 r12343  
    55from zope.interface.verify import verifyObject, verifyClass
    66from zope.schema.interfaces import ConstraintNotSatisfied, WrongType
    7 from waeup.ikoba.interfaces import IProductOption, IProductOptionField, IIkobaUtils
    8 from waeup.ikoba.products.productoptions import ProductOption, ProductOptionField
     7from waeup.ikoba.interfaces import  IIkobaUtils
     8from waeup.ikoba.products.productoptions import (
     9    IProductOption, IProductOptionField, ProductOption, ProductOptionField)
    910from waeup.ikoba.utils.utils import IkobaUtils
    1011
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/converters.py

    r12327 r12343  
    3030from zope.schema.interfaces import IList
    3131from waeup.ikoba.interfaces import (
    32     IObjectConverter, IProductOptionField, IFieldConverter,
     32    IObjectConverter, IFieldConverter,
    3333    DELETION_MARKER, IGNORE_MARKER)
    3434from waeup.ikoba.schema.interfaces import IPhoneNumber
    35 from waeup.ikoba.products.productoptions import ProductOption
     35from waeup.ikoba.products.productoptions import (
     36    IProductOptionField, ProductOption)
    3637
    3738class ExtendedCheckBoxWidget(CheckBoxWidget):
Note: See TracChangeset for help on using the changeset viewer.