Changeset 14227


Ignore:
Timestamp:
25 Oct 2016, 06:19:20 (8 years ago)
Author:
Henrik Bettermann
Message:

Raise TicketError? if course is in 2nd semester but
schoolfee has not yet been fully paid.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.aaue/trunk/src/waeup/aaue/locales/en/LC_MESSAGES/waeup.kofa.po

    r14152 r14227  
    137137msgid "<b>Credits: ${a}</b>"
    138138msgstr "<b>Units: ${a}</b>"
     139
     140msgid "Course ${a} cannot be registered."
     141msgstr ""
     142"Course ${a} cannot be registered. You have to pay for the 2nd semester first."
  • main/waeup.aaue/trunk/src/waeup/aaue/students/studylevel.py

    r14206 r14227  
    2828from waeup.kofa.utils.helpers import attrs_to_fields
    2929from waeup.kofa.interfaces import CREATED
     30from waeup.kofa.students.browser import TicketError
    3031from waeup.kofa.students.studylevel import (
    3132    StudentStudyLevel, CourseTicket,
     
    160161        return 'N/A'
    161162
     163    def _schoolfeePaymentMade(self):
     164        if len(self.student['payments']):
     165            for ticket in self.student['payments'].values():
     166                if ticket.p_state == 'paid' and \
     167                    ticket.p_category in (
     168                        'schoolfee', 'schoolfee_incl', 'schoolfee_2',)  and \
     169                    ticket.p_session == self.student[
     170                        'studycourse'].current_session:
     171                    return True
     172        return False
     173
    162174    def addCourseTicket(self, ticket, course):
    163175        """Add a course ticket object.
     
    166178            raise TypeError(
    167179                'StudentStudyLeves contain only ICourseTicket instances')
     180        # Raise TicketError if course is in 2nd semester but
     181        # schoolfee has not yet been fully paid.
     182        if course.semester == 2 and not self._schoolfeePaymentMade():
     183            raise TicketError
    168184        ticket.code = course.code
    169185        ticket.title = course.title
     
    179195        return
    180196
     197    def addCertCourseTickets(self, cert):
     198        """Collect all certificate courses and create course
     199        tickets automatically.
     200        """
     201        if cert is not None:
     202            for key, val in cert.items():
     203                if val.level != self.level:
     204                    continue
     205                ticket = createObject(u'waeup.CourseTicket')
     206                ticket.automatic = True
     207                ticket.mandatory = val.mandatory
     208                ticket.carry_over = False
     209                try:
     210                    self.addCourseTicket(ticket, val.course)
     211                except TicketError:
     212                    pass
     213        return
     214
    181215CustomStudentStudyLevel = attrs_to_fields(
    182216    CustomStudentStudyLevel, omit=[
  • main/waeup.aaue/trunk/src/waeup/aaue/students/tests/test_browser.py

    r14206 r14227  
    709709        print "Sample PDF pg_course_registration_slip.pdf written to %s" % path
    710710
     711    def test_student_2nd_semester_course_registration(self):
     712        IWorkflowState(self.student).setState('school fee paid')
     713        self.course.semester = 2
     714        self.browser.open(self.login_path)
     715        self.browser.getControl(name="form.login").value = self.student_id
     716        self.browser.getControl(name="form.password").value = 'spwd'
     717        self.browser.getControl("Login").click()
     718        self.browser.getLink("Study Course").click()
     719        self.browser.getLink("Add course list").click()
     720        self.browser.getControl("Create course list now").click()
     721        self.assertFalse('COURSE1' in self.browser.contents)
     722        # 2nd semester tickets can't be added manually
     723        self.browser.getLink("Edit course list").click()
     724        self.browser.getLink("here").click()
     725        self.browser.getControl(name="form.course").value = ['COURSE1']
     726        self.browser.getControl("Add course ticket").click()
     727        self.assertTrue(
     728            'Course COURSE1 cannot be registered. '
     729            'You have to pay for the 2nd semester first.'
     730            in self.browser.contents)
     731        # 2nd instalment has to be paid first
     732        self.certificate.school_fee_3 = 678.0
     733        self.browser.open(self.payments_path + '/addop')
     734        self.browser.getControl(name="form.p_category").value = ['schoolfee_2']
     735        self.browser.getControl("Create ticket").click()
     736        self.student['payments'].values()[0].approve()
     737        self.browser.open(self.studycourse_path + '/100/ctadd')
     738        self.browser.getControl(name="form.course").value = ['COURSE1']
     739        self.browser.getControl("Add course ticket").click()
     740        self.assertTrue('Successfully added COURSE1' in self.browser.contents)
     741        return
     742
    711743    def test_student_clearance(self):
    712744        # Student cant login if their password is not set
Note: See TracChangeset for help on using the changeset viewer.