Changeset 6816


Ignore:
Timestamp:
22 Sep 2011, 12:30:15 (13 years ago)
Author:
Henrik Bettermann
Message:

Application is only allowed between start and end time. Show dates on login page and logout applicants if current time exceeds these limits.

Location:
main/waeup.sirp/trunk/src/waeup/sirp
Files:
4 edited

Legend:

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

    r6724 r6816  
    2525import grok
    2626
    27 from datetime import datetime
     27from datetime import datetime, date
     28from zope.authentication.interfaces import ILogout, IAuthentication
     29from zope.component import getUtility
    2830from zope.formlib.widget import CustomWidgetFactory
    2931from zope.formlib.form import setUpEditWidgets
     
    412414        pin = self.request.principal.access_code
    413415
    414         # Mark pin as used (this also fires a pin related transition)
     416        # If application has not yet started,
     417        # logout without marking AC as used
     418        if self.context.startdate > date.today():
     419            self.flash('Application has not yet started.')
     420            auth = getUtility(IAuthentication)
     421            ILogout(auth).logout(self.request)
     422            self.redirect(self.url(self.context, 'login'))
     423            return
     424
     425        # If application has ended and applicant record doesn't exist,
     426        # logout without marking AC as used
     427        if not pin in self.context.keys() and self.context.enddate < date.today():
     428            self.flash('Application has ended.')
     429            auth = getUtility(IAuthentication)
     430            ILogout(auth).logout(self.request)
     431            self.redirect(self.url(self.context, 'login'))
     432            return
     433
     434        # Mark AC as used (this also fires a pin related transition)
    415435        if get_access_code(pin).state == USED:
    416436            pass
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/browser_templates/loginapplicant.pt

    r6110 r6816  
    5050  </ul>
    5151</div>
    52 <div tal:on-error="nothing">
    53   <div class="error" tal:content="view/getDeadline">
    54     The deadline is NOW
    55   </div>
     52<br />
     53<div>
     54  Start date of application:
     55  <span tal:replace="python: context.startdate.strftime('%d/%m/%Y') ">STARTDATE</span>
    5656</div>
     57<div>
     58  Closing date of application:
     59  <span tal:replace="python: context.enddate.strftime('%d/%m/%Y')">ENDDATE</span>
     60</div>
     61<br />
     62<div tal:condition="context/strict_deadline">
     63  No application after deadline!
     64</div>
  • main/waeup.sirp/trunk/src/waeup/sirp/applicants/tests/test_browser.py

    r6632 r6816  
    2626import tempfile
    2727from StringIO import StringIO
    28 from datetime import datetime
     28from datetime import datetime, date, timedelta
    2929from mechanize import LinkNotFoundError
    3030from zope.component import createObject
     
    8383        applicantscontainer.year = 2009
    8484        applicantscontainer.application_category = 'basic'
     85        delta = timedelta(days=10)
     86        applicantscontainer.startdate = date.today() - delta
     87        applicantscontainer.enddate = date.today() + delta
    8588        self.app['applicants']['app2009'] = applicantscontainer
    8689
     
    350353        appl = appl[pin]
    351354        passp = appl.passport
    352         #import pdb; pdb.set_trace()
    353355        passp_len = len(passp.file.read())
    354356        self.assertEqual(passp_len, PH_LEN)
     
    456458        applicantscontainer = ApplicantsContainer()
    457459        applicantscontainer.ac_prefix = 'APP'
     460        delta = timedelta(days=10)
     461        applicantscontainer.startdate = date.today() - delta
     462        applicantscontainer.enddate = date.today() + delta
    458463        app['applicants']['testapplicants'] = applicantscontainer
    459464
     
    629634    def test_after_login_default_browsable(self):
    630635        # After login we see the placeholder image in the edit view
     636        #import pdb; pdb.set_trace()
    631637        self.login()
    632638        self.assertEqual(self.browser.url, self.edit_path)
  • main/waeup.sirp/trunk/src/waeup/sirp/students/workflow.py

    r6801 r6816  
    22"""
    33import grok
    4 from datetime import datetime
    54from hurry.workflow.workflow import Transition, WorkflowState, NullCondition
    65from hurry.workflow.interfaces import IWorkflowState, IWorkflowTransitionEvent
Note: See TracChangeset for help on using the changeset viewer.