Changeset 12670 for main


Ignore:
Timestamp:
6 Mar 2015, 18:37:06 (10 years ago)
Author:
Henrik Bettermann
Message:

Add a multilingual description field to products.

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

Legend:

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

    r12240 r12670  
    5151    Transition(
    5252        transition_id = 'retract',
    53         title = _('Retract documet'),
     53        title = _('Retract document'),
    5454        source = PUBLISHED,
    5555        condition = NullCondition,
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/browser.py

    r12419 r12670  
    155155    @property
    156156    def form_fields(self):
    157         return grok.AutoFields(
    158             self.context.form_fields_interface).omit('terms_and_conditions')
     157        return grok.AutoFields(self.context.form_fields_interface).omit(
     158            'terms_and_conditions', 'description')
    159159
    160160    @property
    161161    def label(self):
    162162        return self.context.title
     163
     164    @property
     165    def description(self):
     166        lang = self.request.cookies.get('ikoba.language')
     167        html = self.context.description_dict.get(lang,'')
     168        if html =='':
     169            portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
     170            html = self.context.description_dict.get(portal_language,'')
     171        return html
    163172
    164173    @property
     
    198207    def save(self, **data):
    199208        msave(self, **data)
    200         # Save multilingual dict
     209        # Save multilingual dicts
     210        portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
     211        desc = getattr(self.context, 'description', None)
     212        self.context.description_dict = html2dict(desc, portal_language)
    201213        tc = getattr(self.context, 'terms_and_conditions', None)
    202         portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
    203214        self.context.tc_dict = html2dict(tc, portal_language)
    204215        return
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/browser_templates/productpage.pt

    r12362 r12670  
     1<span tal:condition="view/description" tal:omit-tag="">
     2  <p tal:content="structure view/description">Description</p>
     3  <br />
     4</span>
     5
    16<table class="form-table" i18n:domain="waeup.ikoba">
    27  <tbody>
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/container.py

    r12213 r12670  
    2121import grok
    2222from grok import index
     23from waeup.ikoba.interfaces import IIkobaPluggable
    2324from waeup.ikoba.products.interfaces import IProductsContainer, IProduct
    2425from waeup.ikoba.utils.helpers import attrs_to_fields
     
    4041
    4142ProductsContainer = attrs_to_fields(ProductsContainer)
     43
     44
     45class ContainerPlugin(grok.GlobalUtility):
     46    """A plugin that creates container for Container inside a company.
     47    """
     48    grok.implements(IIkobaPluggable)
     49    grok.name('productscontainer')
     50
     51    def setup(self, site, name, logger):
     52        return
     53
     54    def update(self, site, name, logger):
     55        container = site['products']
     56        for value in container.values():
     57            if not getattr(value, 'description_dict', None):
     58                value.description_dict = {}
     59        return
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/interfaces.py

    r12487 r12670  
    9090        )
    9191
     92    description_dict = Attribute(
     93        'Description as language dictionary with values in html format')
     94
     95    description = schema.Text(
     96        title = _(u'Description'),
     97        required = False,
     98        description = _(u'Multilingual content in HTML format'),
     99        )
     100
    92101    tc_dict = Attribute('Terms and Conditions as language dictionary with values in html format')
    93102
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/product.py

    r12592 r12670  
    5252        super(Product, self).__init__(*args, **kw)
    5353        self.tc_dict = {}
     54        self.description_dict = {}
    5455
    5556    @property
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_export.py

    r12361 r12670  
    6262        result = open(self.outfile, 'rb').read()
    6363        self.assertTrue(
    64             'contract_category,contract_title,options,'
     64            'contract_category,contract_title,description,options,'
    6565            'product_id,terms_and_conditions,title,valid_from,valid_to,users_with_local_roles\r\n'
    66             'license,,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",LIC,,Unnamed'
     66            'license,,,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",LIC,,Unnamed'
    6767            ',2015-12-04#,,"[{\'user_name\': u\'john\', \'local_role\': '
    6868            'u\'johnsrole\'}]"\r\n'
     
    7777        result = open(self.outfile, 'rb').read()
    7878        self.assertTrue(
    79             'contract_category,contract_title,options,'
     79            'contract_category,contract_title,description,options,'
    8080            'product_id,terms_and_conditions,title,valid_from,valid_to,users_with_local_roles\r\n'
    81             'license,,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",LIC,,Unnamed'
     81            'license,,,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",LIC,,Unnamed'
    8282            ',2015-12-04#,,"[{\'user_name\': u\'john\', \'local_role\': '
    8383            'u\'johnsrole\'}]"\r\n'
Note: See TracChangeset for help on using the changeset viewer.