Changeset 9502


Ignore:
Timestamp:
2 Nov 2012, 06:13:11 (12 years ago)
Author:
Henrik Bettermann
Message:

Customize addCertCourseTickets. Add ticket only if student has paid for the course.semester. Tests will follow.

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

Legend:

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

    r9496 r9502  
    3737    def getValues(self, context):
    3838        catalog = getUtility(ICatalog, name='courses_catalog')
    39         payments_folder =  context.student['payments']
    40         payments = [(p.p_session, p.p_category, p.p_state)
    41             for p in payments_folder.values()]
    4239        courses = sorted(list(catalog.searchResults(
    4340            code=(None, None))),key=lambda value: value.code)
     41        payments = context.student.getPaymentTuples()
    4442        if (context.student.current_session, 'schoolfee_2', 'paid') in payments:
    4543            pass
  • main/waeup.aaue/trunk/src/waeup/aaue/students/student.py

    r8991 r9502  
    3535    grok.provides(ICustomStudent)
    3636
     37    def getPaymentTuples(self):
     38        """Special AAUE method needed for selecting courses in semesters
     39        the student has paid for.
     40        """
     41        payments = [(p.p_session, p.p_category, p.p_state)
     42            for p in self['payments'].values()]
     43        return payments
    3744
    3845# Set all attributes of Student required in IStudent as field
  • main/waeup.aaue/trunk/src/waeup/aaue/students/studylevel.py

    r8867 r9502  
    2222import grok
    2323from zope.component.interfaces import IFactory
     24from zope.component import createObject
    2425from zope.interface import implementedBy
    2526from waeup.kofa.utils.helpers import attrs_to_fields
     
    3738    grok.implements(ICustomStudentStudyLevel, IStudentNavigation)
    3839    grok.provides(ICustomStudentStudyLevel)
     40
     41    def addCertCourseTickets(self, cert):
     42        """Collect all certificate courses and create course
     43        tickets automatically.
     44
     45        Add ticket only if student has paid for the course.semester.
     46        """
     47        payments = self.student.getPaymentTuples()
     48        if cert is not None:
     49            for key, val in cert.items():
     50                if val.level != self.level:
     51                    continue
     52                if val.course.semester == 2 and \
     53                    not (self.student.current_session,
     54                    'schoolfee_2', 'paid') in payments:
     55                    continue
     56                ticket = createObject(u'waeup.CourseTicket')
     57                ticket.automatic = True
     58                ticket.mandatory = val.mandatory
     59                ticket.carry_over = False
     60                self.addCourseTicket(ticket, val.course)
     61        return
    3962
    4063CustomStudentStudyLevel = attrs_to_fields(CustomStudentStudyLevel)
Note: See TracChangeset for help on using the changeset viewer.