Changeset 8474


Ignore:
Timestamp:
20 May 2012, 11:21:13 (12 years ago)
Author:
Henrik Bettermann
Message:

Enable postgraduate workflow in custom package.

Location:
main/waeup.aaue/trunk/src/waeup/aaue/students
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/students/studycourse.py

    r8444 r8474  
    2121"""
    2222import grok
     23from zope.interface import implementedBy
    2324from waeup.kofa.students.studycourse import (
    2425    StudentStudyCourse, StudentStudyCourseFactory)
     26from waeup.kofa.utils.helpers import attrs_to_fields
     27from waeup.kofa.students.workflow import CLEARED, RETURNING, PAID
    2528from waeup.aaue.students.interfaces import (
    2629    ICustomStudentStudyCourse, IStudentNavigation)
    27 from zope.interface import implementedBy
    28 from waeup.kofa.utils.helpers import attrs_to_fields
    2930
    3031class CustomStudentStudyCourse(StudentStudyCourse):
     
    3637
    3738    @property
    38     def may_register(self):
    39         if self.previous_verdict in (
    40             'A','B','C','F','J','L','M','N','O','X','Z') or \
    41             self.current_level in (0, 100) or\
    42             (self.__parent__.current_mode.startswith('de') and self.current_level == 200) or \
    43             (self.__parent__.current_mode.startswith('ph') and self.current_level == 300):
     39    def next_session_allowed(self):
     40        state = self.getStudent().state
     41        if state == CLEARED:
     42            return True
     43        cond0 = state == RETURNING
     44        cond1 = self.previous_verdict in (
     45            'A','B','C','F','J','L','M','N','O','X','Z')
     46        cond2 = self.current_level in (0, 100)
     47        cond3 = self.getStudent().current_mode.startswith('de') and \
     48            self.current_level == 200
     49        cond4 = self.getStudent().current_mode.startswith('ph') and \
     50            self.current_level == 300
     51        if cond0 and (cond1 or cond2 or cond3 or cond4):
     52            return True
     53        cond5 = self.is_postgrad
     54        cond6 = self.getStudent().state == PAID
     55        if  cond5 and cond6:
    4456            return True
    4557        return False
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r8444 r8474  
    113113        ticket = createObject(u'waeup.CourseTicket')
    114114        verify.verifyObject(ICustomCourseTicket, ticket)
    115         # Let's see if may_register works as expected
     115        IWorkflowState(self.student).setState('returning')
     116        # Let's see if next_session_allowed works as expected
    116117        # A, ug_ft, 100
    117         self.assertTrue(self.student['studycourse'].may_register)
     118        self.assertTrue(self.student['studycourse'].next_session_allowed)
    118119        # O, ug_ft, 100
    119120        self.student['studycourse'].current_verdict = 'O'
    120         self.assertTrue(self.student['studycourse'].may_register)
     121        self.assertTrue(self.student['studycourse'].next_session_allowed)
    121122        # O, ug_ft, 200
    122123        self.student['studycourse'].current_level = 200
    123         self.assertFalse(self.student['studycourse'].may_register)
     124        self.assertFalse(self.student['studycourse'].next_session_allowed)
    124125        # O, de_ft, 200
    125126        self.student['studycourse'].certificate.study_mode = 'de_ft'
    126         self.assertTrue(self.student['studycourse'].may_register)
     127        self.assertTrue(self.student['studycourse'].next_session_allowed)
    127128        # O, ph_ft, 300
    128129        self.student['studycourse'].certificate.study_mode = 'ph_ft'
    129130        self.student['studycourse'].current_level = 300
    130         self.assertTrue(self.student['studycourse'].may_register)
     131        self.assertTrue(self.student['studycourse'].next_session_allowed)
    131132        # O, ph_ft, 400
    132133        self.student['studycourse'].current_level = 400
    133         self.assertFalse(self.student['studycourse'].may_register)
     134        self.assertFalse(self.student['studycourse'].next_session_allowed)
     135
     136        # Now we convert the certificate into a postgraduate certificate
     137        IWorkflowState(self.student).setState('school fee paid')
     138        self.certificate.study_mode = 'pg_ft'
     139        # ... and voila next session registration is allowed
     140        self.assertTrue(self.student['studycourse'].next_session_allowed)
    134141
    135142    def test_manage_access(self):
  • main/waeup.aaue/trunk/src/waeup/aaue/students/utils.py

    r8444 r8474  
    1717##
    1818import grok
    19 from waeup.kofa.interfaces import CLEARED, RETURNING
     19from waeup.kofa.interfaces import CLEARED, RETURNING, PAID
    2020from waeup.kofa.students.utils import StudentsUtils
    2121from waeup.kofa.students.interfaces import IStudentsUtils
     
    9696                # has paid for.
    9797                details['p_session'], details['p_level'] = self.getReturningData(student)
     98            elif student.current_mode.startswith('pg') and student.state == PAID:
     99                # Returning postgraduate students also pay for the next session
     100                # but their level always remains the same.
     101                details['p_session'] += 1
     102                details['amount'] = getattr(
     103                    student['studycourse'].certificate,'school_fee_2')
    98104        if details['amount'] in (0.0, None):
    99105            details['error'] = _(u'Amount could not be determined.')
Note: See TracChangeset for help on using the changeset viewer.