Changeset 9824


Ignore:
Timestamp:
5 Jan 2013, 13:48:04 (12 years ago)
Author:
Henrik Bettermann
Message:

delCertCourse deletes all certificate courses referring to the same course if level is not given. This has caused a KeyError? in handle_course_removed.

Tests will follow.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/university
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/university/certificate.py

    r9341 r9824  
    7575
    7676    def delCertCourse(self, code, level=None):
    77         """Delete a certificate course denoted by its code.
     77        """Delete certificate courses.
     78
     79        We might have more than one certificate course for a course.
     80        If level is not provided all certificate courses referring
     81        to the same course will be deleted.
    7882        """
    7983        keys = list(self.keys()) # create list copy
  • main/waeup.kofa/trunk/src/waeup/kofa/university/course.py

    r9227 r9824  
    7575    code = course.code
    7676
    77     # Find all certificatecourses that refer to given course...
     77    # Find all certificatecourses that refer to given course
    7878    try:
    7979        cat = getUtility(ICatalog, name='certcourses_catalog')
     
    8383
    8484    results = cat.searchResults(course_code=(code, code))
     85    # Only one certcourse per certificate is needed
     86    reduced_results = []
    8587    for certcourse in results:
    86         # Remove that referrer...
     88        cert = certcourse.__parent__
     89        if cert in  [i.__parent__ for i in reduced_results]:
     90            continue
     91        reduced_results.append(certcourse)
     92    # Now we can apply delCertCourse
     93    for certcourse in reduced_results:
    8794        cert = certcourse.__parent__
    8895        cert.delCertCourse(code)
    89         cert._p_changed = True
    9096    return
    9197
Note: See TracChangeset for help on using the changeset viewer.