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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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=[
Note: See TracChangeset for help on using the changeset viewer.