Changeset 12634 for main


Ignore:
Timestamp:
27 Feb 2015, 21:56:34 (10 years ago)
Author:
Henrik Bettermann
Message:

Show validity period on contract pages and slips.

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  
    3434from waeup.ikoba.interfaces import IIkobaObject, IUserAccount, IIkobaUtils
    3535from waeup.ikoba.interfaces import MessageFactory as _
    36 from waeup.ikoba.utils.helpers import to_timezone
     36from waeup.ikoba.utils.helpers import to_timezone, format_date
    3737from waeup.ikoba.authentication import get_principal_role_manager
    3838from waeup.ikoba.browser.interfaces import ICustomerNavigationBase
     
    284284
    285285    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)
    290287           
    291288    def formatTZDate(self,datetimeobj):
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser.py

    r12633 r12634  
    5151from waeup.ikoba.mandates.mandate import PasswordMandate
    5252from waeup.ikoba.widgets.hrefwidget import HREFDisplayWidget
    53 from waeup.ikoba.utils.helpers import get_current_principal, to_timezone, now
     53from waeup.ikoba.utils.helpers import (
     54    get_current_principal, to_timezone, now, format_date)
    5455from waeup.ikoba.customers.interfaces import (
    5556    ICustomer, ICustomersContainer, ICustomerRequestPW, ICustomersUtils,
     
    15931594
    15941595    @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
    15951603    def label(self):
    15961604        portal_language = getUtility(IIkobaUtils).PORTAL_LANGUAGE
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/browser_templates/contractpage.pt

    r12593 r12634  
    2626    </tr>
    2727    <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>
    2841  </tbody>
    2942</table>
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/tests/test_browser.py

    r12593 r12634  
    14441444        self.contract.product_object = self.product
    14451445        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'
    14461448        self.contract.title = u'Contract Title'
    14471449        self.browser.open(self.customer_path + '/contracts/CON1')
  • main/waeup.ikoba/trunk/src/waeup/ikoba/customers/utils.py

    r12526 r12634  
    410410                data.extend(creator.fromStringList(customer.history.messages))
    411411
     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
    412419        # Insert content tables (optionally on second page)
    413         if hasattr(view, 'tabletitle'):
     420        if getattr(view, 'tabletitle', None):
    414421            for i in range(len(view.tabletitle)):
    415422                if tabledata[i] and tableheader[i]:
     
    422429
    423430        # Insert terms and conditions
    424         if hasattr(view, 'terms_and_conditions'):
     431        if getattr(view, 'terms_and_conditions', None):
    425432            tc_translation = trans(_('Terms and Conditions'), portal_language)
    426433            data.append(Paragraph(tc_translation, HEADING_STYLE))
  • main/waeup.ikoba/trunk/src/waeup/ikoba/utils/helpers.py

    r12408 r12634  
    3030from cStringIO import StringIO
    3131from docutils.core import publish_string
     32from zope.i18n import translate
    3233from zope.component import getUtility
    3334from zope.component.interfaces import IFactory
     
    4041from zope.pluggableauth.interfaces import IAuthenticatorPlugin
    4142from zope.formlib.widget import renderElement
     43from waeup.ikoba.interfaces import MessageFactory as _
    4244
    4345BUFSIZE = 8 * 1024
     
    859861                contents=ReST2HTML(text))
    860862    return elements
     863
     864def 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.