Ignore:
Timestamp:
7 Mar 2015, 08:15:26 (10 years ago)
Author:
Henrik Bettermann
Message:

Add multilingual description field to products container.

Location:
main/waeup.ikoba/trunk/src/waeup/ikoba/products
Files:
5 edited

Legend:

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

    r12670 r12684  
    7979    label = _('Products')
    8080
     81    @property
     82    def description(self):
     83        lang = self.request.cookies.get('ikoba.language')
     84        html = self.context.description_dict.get(lang,'')
     85        if html =='':
     86            portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
     87            html = self.context.description_dict.get(portal_language,'')
     88        return html
     89
    8190
    8291class ProductsContainerManageFormPage(IkobaEditFormPage,
     
    106115    @action(_('Save'), style='primary')
    107116    def save(self, **data):
    108         return msave(self, **data)
     117        msave(self, **data)
     118        # Save multilingual dict
     119        portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
     120        desc = getattr(self.context, 'description', None)
     121        self.context.description_dict = html2dict(desc, portal_language)
     122        return
    109123
    110124    @action(_('Cancel'), validator=NullValidator)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/browser_templates/containermanagepage.pt

    r12413 r12684  
    1515  <div class="tab-content">
    1616    <div id="tab1" class="active tab-pane">
     17      <br />
    1718      <table class="form-table">
    1819        <tbody>
     
    2021        </tbody>
    2122      </table>
    22       <br /><p i18n:translate="">Setting parameters no yet configured.</p>
    2323      <div tal:condition="view/availableActions">
    2424        <span tal:repeat="action view/actions" tal:omit-tag="">
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/browser_templates/containerpage.pt

    r12592 r12684  
     1<span tal:condition="view/description" tal:omit-tag="">
     2  <p tal:content="structure view/description">Description</p>
     3  <br /><br />
     4</span>
     5
    16<div i18n:domain="waeup.ikoba" i18n:translate="" tal:condition="python: not len(context.keys())">
    27There are no subobjects registered yet.
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/container.py

    r12670 r12684  
    3232    grok.provides(IProductsContainer)
    3333
     34    def __init__(self, *args, **kw):
     35        super(ProductsContainer, self).__init__(*args, **kw)
     36        self.description_dict = {}
    3437
    3538    def addProduct(self, product):
     
    5457    def update(self, site, name, logger):
    5558        container = site['products']
     59        if not getattr(container, 'description_dict', None):
     60            container.description_dict = {}
    5661        for value in container.values():
    5762            if not getattr(value, 'description_dict', None):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/interfaces.py

    r12670 r12684  
    3636
    3737    """
     38
     39    description_dict = Attribute(
     40        'Description as language dictionary with values in html format')
     41
     42    description = schema.Text(
     43        title = _(u'Description'),
     44        required = False,
     45        description = _(u'Multilingual content in HTML format'),
     46        )
    3847
    3948    def addProduct(product):
Note: See TracChangeset for help on using the changeset viewer.