- Timestamp:
- 27 Feb 2015, 21:56:34 (10 years ago)
- Location:
- main/waeup.ikoba/trunk/src/waeup/ikoba
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.ikoba/trunk/src/waeup/ikoba/browser/layout.py
r12576 r12634 34 34 from waeup.ikoba.interfaces import IIkobaObject, IUserAccount, IIkobaUtils 35 35 from waeup.ikoba.interfaces import MessageFactory as _ 36 from waeup.ikoba.utils.helpers import to_timezone 36 from waeup.ikoba.utils.helpers import to_timezone, format_date 37 37 from waeup.ikoba.authentication import get_principal_role_manager 38 38 from waeup.ikoba.browser.interfaces import ICustomerNavigationBase … … 284 284 285 285 def formatDate(self,dateobj): 286 if isinstance(dateobj, date): 287 return dateobj.strftime("%d/%m/%Y") 288 else: 289 return None 286 return format_date(dateobj, self.request) 290 287 291 288 def formatTZDate(self,datetimeobj): -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py
r12633 r12634 51 51 from waeup.ikoba.mandates.mandate import PasswordMandate 52 52 from waeup.ikoba.widgets.hrefwidget import HREFDisplayWidget 53 from waeup.ikoba.utils.helpers import get_current_principal, to_timezone, now 53 from waeup.ikoba.utils.helpers import ( 54 get_current_principal, to_timezone, now, format_date) 54 55 from waeup.ikoba.customers.interfaces import ( 55 56 ICustomer, ICustomersContainer, ICustomerRequestPW, ICustomersUtils, … … 1593 1594 1594 1595 @property 1596 def validity_period(self): 1597 if self.context.valid_from or self.context.valid_to: 1598 return "%s - %s" % (format_date(self.context.valid_from, self.request), 1599 format_date(self.context.valid_to, self.request)) 1600 return 1601 1602 @property 1595 1603 def label(self): 1596 1604 portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/contractpage.pt
r12593 r12634 26 26 </tr> 27 27 <tal:widgets content="structure provider:widgets" /> 28 <tr> 29 <td i18n:translate="" class="fieldname"> 30 Validity Period: 31 </td> 32 <td> 33 <span tal:content="python: layout.formatDate(context.valid_from)"> 34 VALIDFROM 35 </span> - 36 <span tal:content="python: layout.formatDate(context.valid_to)"> 37 VALIDTO 38 </span> 39 </td> 40 </tr> 28 41 </tbody> 29 42 </table> -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py
r12593 r12634 1444 1444 self.contract.product_object = self.product 1445 1445 self.contract.tc_dict = {'en': u'<strong>Hello world</strong>'} 1446 self.contract.valid_from = date(2015, 12, 4) 1447 self.contract.valid_to = 'anything' 1446 1448 self.contract.title = u'Contract Title' 1447 1449 self.browser.open(self.customer_path + '/contracts/CON1') -
main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py
r12526 r12634 410 410 data.extend(creator.fromStringList(customer.history.messages)) 411 411 412 # Insert validity period 413 if getattr(view, 'validity_period', None): 414 vp_translation = trans(_('Validity Period'), portal_language) 415 data.append(Paragraph(vp_translation, HEADING_STYLE)) 416 vp = view.validity_period 417 data.append(Paragraph(vp, NOTE_STYLE)) 418 412 419 # Insert content tables (optionally on second page) 413 if hasattr(view, 'tabletitle'):420 if getattr(view, 'tabletitle', None): 414 421 for i in range(len(view.tabletitle)): 415 422 if tabledata[i] and tableheader[i]: … … 422 429 423 430 # Insert terms and conditions 424 if hasattr(view, 'terms_and_conditions'):431 if getattr(view, 'terms_and_conditions', None): 425 432 tc_translation = trans(_('Terms and Conditions'), portal_language) 426 433 data.append(Paragraph(tc_translation, HEADING_STYLE)) -
main/waeup.ikoba/trunk/src/waeup/ikoba/utils/helpers.py
r12408 r12634 30 30 from cStringIO import StringIO 31 31 from docutils.core import publish_string 32 from zope.i18n import translate 32 33 from zope.component import getUtility 33 34 from zope.component.interfaces import IFactory … … 40 41 from zope.pluggableauth.interfaces import IAuthenticatorPlugin 41 42 from zope.formlib.widget import renderElement 43 from waeup.ikoba.interfaces import MessageFactory as _ 42 44 43 45 BUFSIZE = 8 * 1024 … … 859 861 contents=ReST2HTML(text)) 860 862 return elements 863 864 def format_date(dateobj, request): 865 if isinstance(dateobj, datetime.date): 866 return dateobj.strftime("%d/%m/%Y") 867 else: 868 return translate(_('indefinite'), context=request)
Note: See TracChangeset for help on using the changeset viewer.