Ignore:
Timestamp:
29 Nov 2014, 17:37:58 (10 years ago)
Author:
Henrik Bettermann
Message:

Add product field with source AppCatProductSource? for filtering products.

  • work in progress -
Location:
main/waeup.ikoba/trunk/src/waeup/ikoba
Files:
4 edited

Legend:

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

    r12090 r12092  
    6262    grok.provides(IApplication)
    6363    grok.baseclass()
     64
     65    application_category = None
    6466
    6567    def __init__(self):
     
    139141    """
    140142
     143    application_category = 'sample'
     144
    141145SampleApplication = attrs_to_fields(SampleApplication)
    142146
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/interfaces.py

    r12090 r12092  
    2929
    3030from waeup.ikoba.customers.vocabularies import (
    31     contextual_reg_num_source, GenderSource, nats_vocab)
     31    contextual_reg_num_source, GenderSource, nats_vocab, AppCatProductSource)
    3232
    3333
     
    270270        'Returns a translated, more verbose appliction state')
    271271    class_name = Attribute('Name of the application class')
    272     formatted_transition_date = Attribute('Last transition formatted date string')
     272    formatted_transition_date = Attribute(
     273        'Last transition formatted date string')
     274    application_category = Attribute('Category for the grouping of products')
    273275
    274276    title = schema.TextLine(
     
    282284        readonly = False,
    283285        )
     286
     287    product = schema.Choice(
     288        title = _(u'Product'),
     289        source = AppCatProductSource(),
     290        required = False,
     291        )
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/vocabularies.py

    r11997 r12092  
    1 ## $Id: vocabularies.py 9778 2012-12-06 15:45:03Z henrik $
     1## $Id$
    22##
    33## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
     
    1818"""Vocabularies and sources for the customer section.
    1919"""
     20import grok
    2021from zope.component import getUtility, queryUtility
    2122from zope.catalog.interfaces import ICatalog
     
    2930from waeup.ikoba.utils.helpers import get_sorted_preferred
    3031from waeup.ikoba.utils.countries import COUNTRIES
     32from waeup.ikoba.sourcefactory import SmartBasicContextualSourceFactory
    3133
    3234
     
    116118
    117119directlyProvides(contextual_reg_num_source, IContextSourceBinder)
     120
     121
     122class AppCatProductSource(SmartBasicContextualSourceFactory):
     123    """An application category product delivers all products
     124    which belong to a certain application_category.
     125    """
     126    def contains(self, context, value):
     127        appcat = getattr(context, 'application_category', None)
     128        if value.application_category == appcat:
     129            return True
     130        return False
     131
     132    def getValues(self, context):
     133        appcat = getattr(context, 'application_category', None)
     134        products = grok.getSite()['products'].values()
     135        if not appcat:
     136            return products   # ?????????????????
     137        resultlist = [
     138            value for value in products if value.application_category == appcat]
     139        return resultlist
     140
     141    def getToken(self, context, value):
     142        return value.product_id
     143
     144    def getTitle(self, context, value):
     145        return "%s - %s" % (value.product_id, value.title)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/utils.py

    r12078 r12092  
    103103
    104104    APP_CATS_DICT = {
     105        'sample': 'Sample Category',
    105106        'license': 'License',
    106107        'no': 'no application',
Note: See TracChangeset for help on using the changeset viewer.