Ignore:
Timestamp:
24 Oct 2011, 10:23:11 (13 years ago)
Author:
Henrik Bettermann
Message:

Implement purchase_accesscode function which creates access codes for student online payments (tests will follow).

File:
1 edited

Legend:

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

    r6930 r6936  
    2121from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
    2222from zope.component import createObject
    23 from waeup.sirp.accesscodes import invalidate_accesscode, get_access_code
     23from waeup.sirp.accesscodes import (
     24    invalidate_accesscode, get_access_code, purchase_accesscode)
    2425from waeup.sirp.accesscodes.workflow import USED
    2526from waeup.sirp.browser import (
     
    924925    # from the incoming request.
    925926    def update(self):
     927        student = self.context.getStudent()
    926928        self.context.r_amount_approved = self.context.amount_auth
    927929        self.context.r_card_num = u'0000'
     
    930932        self.context.payment_date = datetime.now()
    931933        if self.context.p_category == 'clearance':
    932             # Find valid CLR access code
    933             pass
     934            # Create CLR access code
     935            pin, error = purchase_accesscode('CLR',0,student.student_id)
     936            if error:
     937                self.flash(error)
     938                return
     939            self.context.ac = pin
     940            return
    934941        elif self.context.p_category == 'schoolfee':
    935             # Find valid SFE access code
    936             pass
    937         return
     942            # Create SFE access code
     943            pin, error = purchase_accesscode('SFE',0)
     944            if error:
     945                self.flash(error)
     946                return
     947            self.context.ac = pin
     948            return
    938949
    939950    def render(self):
     
    10761087
    10771088    def update(self, SUBMIT=None):
     1089        if not self.context.state == 'admitted':
     1090            self.flash("Wrong state.")
     1091            self.redirect(self.url(self.context))
     1092            return
    10781093        self.ac_series = self.request.form.get('ac_series', None)
    10791094        self.ac_number = self.request.form.get('ac_number', None)
     
    10841099        code = get_access_code(pin)
    10851100        if not code:
    1086             self.flash('Access code is invalid.')
     1101            self.flash('Activation code is invalid.')
    10871102            return
    10881103        # Mark pin as used (this also fires a pin related transition)
    10891104        # and fire transition start_clearance
    10901105        if code.state == USED:
    1091             self.flash('Access code has already been used.')
     1106            self.flash('Activation code has already been used.')
    10921107            return
    10931108        else:
Note: See TracChangeset for help on using the changeset viewer.