Ignore:
Timestamp:
5 Jun 2015, 14:35:19 (9 years ago)
Author:
Henrik Bettermann
Message:

Activate and customize late course registration payment. Fresh students can register without restriction.

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

Legend:

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

    r10480 r13036  
    2121"""
    2222import grok
     23import pytz
     24from datetime import datetime
    2325from zope.component.interfaces import IFactory
    2426from zope.component import createObject
    2527from zope.interface import implementedBy
    2628from waeup.kofa.utils.helpers import attrs_to_fields
     29from waeup.kofa.interfaces import CREATED
    2730from waeup.kofa.students.studylevel import (
    2831    StudentStudyLevel, CourseTicket,
     
    5861    def gpa_params_rectified(self):
    5962        return self.gpa_params
     63
     64    @property
     65    def course_registration_allowed(self):
     66        if self.student.is_fresh:
     67            return True
     68        try:
     69            deadline = grok.getSite()['configuration'][
     70                    str(self.level_session)].coursereg_deadline
     71        except TypeError, KeyError:
     72            return True
     73        payment_made = False
     74        if len(self.student['payments']):
     75            for ticket in self.student['payments'].values():
     76                if ticket.p_category == 'late_registration' and \
     77                    ticket.p_session == self.level_session and \
     78                    ticket.p_state == 'paid':
     79                        payment_made = True
     80        if deadline and deadline < datetime.now(pytz.utc) and not payment_made:
     81            return False
     82        return True
    6083
    6184CustomStudentStudyLevel = attrs_to_fields(
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r13035 r13036  
    264264            '2004'].coursereg_deadline = datetime.now(pytz.utc) - delta
    265265        IWorkflowState(self.student).setState('school fee paid')
     266        # Current session is 2004. Here we test course registration for
     267        # returning students.
     268        self.student['studycourse'].entry_session = 2003
    266269        self.browser.open(self.login_path)
    267270        self.browser.getControl(name="form.login").value = self.student_id
     
    290293        self.assertTrue('Course list has been registered' in self.browser.contents)
    291294        self.assertEqual(self.student.state, 'courses registered')
     295        # Reset student and check if fresh students are always allowed to
     296        # register courses.
     297        self.student['studycourse'].entry_session = 2004
     298        del self.student['payments'][value]
     299        IWorkflowState(self.student).setState('school fee paid')
     300        self.browser.open(self.studycourse_path + '/100/edit')
     301        self.browser.getControl("Register course list").click()
     302        self.assertTrue('Course list has been registered' in self.browser.contents)
     303        return
     304
    292305
    293306    def deactivated_test_student_course_registration(self):
    294 
    295307        # Add more courses
    296308        self.course2 = createObject('waeup.Course')
Note: See TracChangeset for help on using the changeset viewer.