Ignore:
Timestamp:
1 Jan 2015, 21:56:40 (10 years ago)
Author:
Henrik Bettermann
Message:

Store 'terms and conditions' of products.

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

    r12318 r12361  
    4141    FriendlyDatetimeDisplayWidget)
    4242from waeup.ikoba.browser.breadcrumbs import Breadcrumb
     43from waeup.ikoba.utils.helpers import html2dict
    4344from waeup.ikoba.browser.pages import (
    4445    delSubobjects, add_local_role, del_local_roles, msave,
     
    189190            if not new:
    190191               del data['options']
    191         return msave(self, **data)
     192        msave(self, **data)
     193        # Save multilingual dict
     194        tc = getattr(self.context, 'terms_and_conditions', None)
     195        portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
     196        self.context.tc_dict = html2dict(tc, portal_language)
     197        return
    192198
    193199    @action(_('Cancel'), validator=NullValidator)
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/interfaces.py

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

    r12336 r12361  
    4545        'waeup.local.ProductManager',
    4646        ]
     47
     48    def __init__(self, *args, **kw):
     49        super(Product, self).__init__(*args, **kw)
     50        self.tc_dict = {}
    4751
    4852    @property
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_browser.py

    r12358 r12361  
    193193        self.assertEqual(self.browser.url, self.manage_product_path)
    194194        self.browser.getControl(name="form.title").value = 'New license'
     195        self.browser.getControl(name="form.terms_and_conditions").value = """
     196<h1>Hello World</h1>
     197>>de<<
     198<h1>Hallo Welt</h1>
     199"""
    195200        self.browser.getControl("Save").click()
    196201        self.assertEqual(self.app['products']['LIC'].title, 'New license')
     202        # tc_dict has been saved
     203        self.assertEqual(self.app['products']['LIC'].tc_dict,
     204            {'de': u'<div id="html">\n<h1>Hallo Welt</h1>\n</div id="html">',
     205             'en': u'<div id="html">\n<h1>Hello World</h1>\n</div id="html">'})
    197206        # Managers can asign local roles
    198207        self.browser.getControl(name="user").value = ['john']
  • main/waeup.ikoba/trunk/src/waeup/ikoba/products/tests/test_export.py

    r12358 r12361  
    6363        self.assertTrue(
    6464            'contract_category,contract_title,options,'
    65             'product_id,title,valid_from,valid_to,users_with_local_roles\r\n'
    66             'license,,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",LIC,Unnamed'
     65            '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'
    6767            ',2015-12-04#,,"[{\'user_name\': u\'john\', \'local_role\': '
    6868            'u\'johnsrole\'}]"\r\n'
     
    7878        self.assertTrue(
    7979            'contract_category,contract_title,options,'
    80             'product_id,title,valid_from,valid_to,users_with_local_roles\r\n'
    81             'license,,"[(u\'Base Fee\', u\'800.6\', u\'USD\')]",LIC,Unnamed'
     80            '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'
    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.