Changeset 12378 for main/waeup.ikoba


Ignore:
Timestamp:
3 Jan 2015, 13:41:03 (10 years ago)
Author:
Henrik Bettermann
Message:

Ease customization of courrencies. Use source instead of vocabulary in interfaces.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.ikoba/trunk/src/waeup/ikoba/interfaces.py

    r12343 r12378  
    205205        return value
    206206
     207class CurrencySource(BasicSourceFactory):
     208    """A source for currencies.
     209    """
     210    def getValues(self):
     211        currencies = getUtility(IIkobaUtils).CURRENCIES
     212        return currencies.keys()
     213
     214    def getToken(self, value):
     215        return value
     216
     217    def getTitle(self, value):
     218        currencies = getUtility(IIkobaUtils).CURRENCIES
     219        return currencies[value][1]
     220
    207221class IIkobaUtils(Interface):
    208222    """A collection of methods which are subject to customization.
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/productoptions.py

    r12343 r12378  
    2727from zope.schema.fieldproperty import FieldProperty
    2828from zope.schema import Object
    29 from waeup.ikoba.interfaces import SimpleIkobaVocabulary
     29from waeup.ikoba.interfaces import CurrencySource
    3030from waeup.ikoba.interfaces import MessageFactory as _
    3131from waeup.ikoba.widgets.objectwidget import (
    3232    IkobaObjectWidget, IkobaObjectDisplayWidget
    3333    )
    34 from waeup.ikoba.payments.currencies import ISO_4217_CURRENCIES_VOCAB as currencies
    3534
    36 #currencies = SimpleIkobaVocabulary(
    37 #    (_('NGN'),'NGN'),
    38 #    (_('USD'),'USD'),
    39 #    (_('EUR'),'EUR'),
    40 #    )
    4135
    4236class IProductOption(Interface):
     
    5448    currency = schema.Choice(
    5549        title = _(u'Currency'),
    56         vocabulary = currencies,
     50        source = CurrencySource(),
    5751        required = False,
    5852        )
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/utils.py

    r12339 r12378  
    2828from waeup.ikoba.smtp import send_mail as send_mail_internally
    2929from waeup.ikoba.utils.helpers import get_sorted_preferred
     30from waeup.ikoba.payments.currencies import ISO_4217_CURRENCIES
    3031
    3132
     
    9596        'ig': (6, u'Igbo'),
    9697        }
     98
     99    # CURRENCIES must be equal to or an excerpt of ISO_4217_CURRENCIES
     100    CURRENCIES = ISO_4217_CURRENCIES
    97101
    98102    #: A function to return
Note: See TracChangeset for help on using the changeset viewer.