Changeset 8200 for main


Ignore:
Timestamp:
17 Apr 2012, 23:35:24 (13 years ago)
Author:
uli
Message:
  • Use datetime for applicants containers and
  • Register new datetime widget as default for entering datetimes.

Fixed all tests to work with the new stuff.

As this is just a quick shot I put all changes into one commit
to ease any later rollback.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r8194 r8200  
    1919"""
    2020import os
     21import pytz
    2122import sys
    2223import grok
     
    877878    def update(self):
    878879        # Check if application has started ...
    879         if not self.context.startdate or self.context.startdate > date.today():
     880        if not self.context.startdate or (
     881            self.context.startdate > datetime.now(pytz.utc)):
    880882            self.flash(_('Application has not yet started.'))
    881883            self.redirect(self.url(self.context))
    882884            return
    883885        # ... or ended
    884         if not self.context.enddate or self.context.enddate < date.today():
     886        if not self.context.enddate or (
     887            self.context.enddate < datetime.now(pytz.utc)):
    885888            self.flash(_('Application has ended.'))
    886889            self.redirect(self.url(self.context))
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py

    r8176 r8200  
    221221        """Content as language dictionary with values in HTML format.""")
    222222
    223     startdate = FormattedDate(
     223    startdate = schema.Datetime(
    224224        title = _(u'Application Start Date'),
    225225        required = False,
    226         show_year = False,
    227         )
    228 
    229     enddate = FormattedDate(
     226        #show_year = False,
     227        )
     228
     229    enddate = schema.Datetime(
    230230        title = _(u'Application Closing Date'),
    231231        required = False,
    232         show_year = False,
     232        #show_year = False,
    233233        )
    234234
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_batching.py

    r8008 r8200  
    2020import datetime
    2121import os
     22import pytz
    2223import shutil
    2324import tempfile
     
    157158            u'>>de<<\nDieser Text kann von anonymen Benutzern '
    158159            u'gelesen werden.')
    159         self.assertEqual(container.startdate, datetime.date(2012, 3, 1))
    160         self.assertEqual(container.enddate, datetime.date(2012, 4, 25))
     160        self.assertEqual(container.startdate,
     161                         datetime.datetime(2012, 3, 1, 0, 0, tzinfo=pytz.utc))
     162        self.assertEqual(container.enddate,
     163                         datetime.datetime(2012, 4, 25, 0, 0, tzinfo=pytz.utc))
    161164        shutil.rmtree(os.path.dirname(fin_file))
    162165
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r8069 r8200  
    1919Test the applicant-related UI components.
    2020"""
     21import pytz
    2122import shutil
    2223import tempfile
     
    8990        applicantscontainer.mode = 'create'
    9091        delta = timedelta(days=10)
    91         applicantscontainer.startdate = date.today() - delta
    92         applicantscontainer.enddate = date.today() + delta
     92        applicantscontainer.startdate = datetime.now(pytz.utc) - delta
     93        applicantscontainer.enddate = datetime.now(pytz.utc) + delta
    9394        self.app['applicants']['app2009'] = applicantscontainer
    9495        self.applicantscontainer = self.app['applicants']['app2009']
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_export.py

    r8069 r8200  
    11import datetime
    22import os
     3import pytz
    34import shutil
    45import tempfile
     
    5657        container.description = u'Some Description\nwith linebreak\n'
    5758        container.description += u'<<de>>man spriht deutsh'
    58         container.startdate = datetime.date(2012, 1, 1)
    59         container.enddate = datetime.date(2012, 1, 31)
     59        container.startdate = datetime.datetime(
     60            2012, 1, 1, 12, 0, 0, tzinfo=pytz.utc)
     61        container.enddate = datetime.datetime(
     62            2012, 1, 31, 23, 0, 0, tzinfo=pytz.utc)
    6063        return container
    6164
     
    7477            'dp2012,General Studies 2012/13,app,100,2012,basic,'
    7578            '"Some Description\nwith linebreak\n<<de>>man spriht deutsh",'
    76             '2012-01-01,2012-01-31,1\r\n'
     79            '2012-01-01 12:00:00+00:00,2012-01-31 23:00:00+00:00,1\r\n'
    7780            )
    7881        return
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py

    r8167 r8200  
    639639        self.assertEqual(payment.p_id, 'p1290797973744')
    640640        cdate = payment.creation_date.strftime("%Y-%m-%d %H:%M:%S")
    641         self.assertEqual(cdate, "2010-11-26 19:59:33")
    642         self.assertEqual(str(payment.creation_date.tzinfo),'tzinfo(60)')
     641        self.assertEqual(cdate, "2010-11-26 18:59:33")
     642        self.assertEqual(str(payment.creation_date.tzinfo),'UTC')
    643643        shutil.rmtree(os.path.dirname(fin_file))
    644644
  • main/waeup.kofa/trunk/src/waeup/kofa/widgets/overrides.zcml

    r8171 r8200  
    3434      />
    3535
     36  <!-- Register pytz-aware edit widget for datetimes -->
     37  <adapter
     38      for="zope.schema.interfaces.IDatetime
     39           zope.publisher.interfaces.browser.IBrowserRequest"
     40      provides="zope.formlib.interfaces.ISimpleInputWidget"
     41      factory="waeup.kofa.widgets.datetimewidget.PytzDatetimeWidget"
     42      permission="zope.Public"
     43      />
     44
    3645</configure>
Note: See TracChangeset for help on using the changeset viewer.