Changeset 6920 for main/waeup.sirp


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

Provide a getPaymentDetails function which requires a SessionConfiguration? object. This function is for demonstration and testing only.

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

Legend:

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

    r6918 r6920  
    1919import grok
    2020from zope.component.interfaces import IFactory
     21from zope.interface import implementedBy
    2122from waeup.sirp.interfaces import (
    2223    ISessionConfiguration, IConfigurationContainer, ISessionConfigurationAdd,
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r6912 r6920  
    881881            payment.surcharge_1,
    882882            payment.surcharge_2,
    883             payment.surcharge_3)  = getPaymentDetails(
     883            payment.surcharge_3,
     884            error)  = getPaymentDetails(
    884885            data['p_category'],self.context.__parent__)
    885         #if payment.amount_auth == 0:
    886         #    self.flash('Payment amount could not be determined.')
    887         #    self.redirect(self.url(self.context, u'@@manage'))
    888         #    return
     886        if error:
     887            self.flash(error)
     888            self.redirect(self.url(self.context, u'@@manage'))
     889            return
    889890        self.context[payment.p_id] = payment
    890891        self.flash('Payment ticket created.')
  • main/waeup.sirp/trunk/src/waeup/sirp/students/tests/test_browser.py

    r6914 r6920  
    3434from waeup.sirp.testing import FunctionalLayer, FunctionalTestCase
    3535from waeup.sirp.app import University
     36from waeup.sirp.configuration import SessionConfiguration
    3637from waeup.sirp.students.student import Student
    3738from waeup.sirp.university.faculty import Faculty
     
    8081        # to access grok.getSite() and should get our new app then
    8182        setSite(app)
     83
     84        # Set up SessionConfiguration object
     85        configuration = SessionConfiguration()
     86        configuration.academic_session = 2004
     87        configuration.fee_1 = 20000
     88        self.app['configuration'].addSessionConfiguration(configuration)
    8289
    8390        # Add student with subobjects
  • main/waeup.sirp/trunk/src/waeup/sirp/students/utils.py

    r6915 r6920  
    11"""General helper functions for the student section.
    22"""
    3 
     3from grok import getSite
    44from random import SystemRandom as r
    55from waeup.sirp.interfaces import academic_sessions_vocab
     
    2121    return
    2222
    23 # To be defined in customization packages
     23# To be specified in customization packages.
     24# This function is for demonstration and testing only.
    2425def getPaymentDetails(category, student):
    25     p_session = None
    2626    surcharge_1 = surcharge_2 = surcharge_3 = 0
    2727    p_item = u''
    2828    amount = 0
    29     return amount, p_item, p_session, surcharge_1, surcharge_2, surcharge_3
     29    error = u''
     30    p_session = student['studycourse'].current_session
     31    session = str(p_session)
     32    try:
     33        academic_session = getSite()['configuration'][session]
     34    except KeyError:
     35        error = u'Session configuration object is not available.'
     36        return (amount, p_item, p_session,
     37            surcharge_1, surcharge_2, surcharge_3, error)
     38    if category == 'schoolfee':
     39        amount = academic_session.fee_1
     40        surcharge_1 = academic_session.fee_2
     41        p_item = student['studycourse'].certificate.code
     42    return (amount, p_item, p_session,
     43        surcharge_1, surcharge_2, surcharge_3, error)
Note: See TracChangeset for help on using the changeset viewer.