Ignore:
Timestamp:
5 Jan 2013, 17:26:01 (12 years ago)
Author:
uli
Message:

Simplify last fix a bit and add regression test. Welcome home, by the way.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/university/certcourses.txt

    r8920 r9828  
    115115    >>> list(fac['DEPT2'].courses)
    116116    [u'CRS2']
     117
     118If a single course is registered for several levels in a single
     119certificate, this will not block things if the course is removed
     120(regression test):
     121
     122We add the same course as a reference for level 200 and level 300:
     123
     124    >>> fac['DEPT'].certificates['CERT'].addCertCourse(
     125    ...   fac['DEPT2'].courses['CRS2'], level=200)
     126    >>> fac['DEPT'].certificates['CERT'].addCertCourse(
     127    ...   fac['DEPT2'].courses['CRS2'], level=300)
     128
     129Deleting the course (thus also the refererrers) will work:
     130
     131    >>> del root['app']['faculties']['FAC']['DEPT2'].courses['CRS2']
     132
     133Now all references are gone:
     134
     135    >>> list(a.certificates['CERT'])
     136    []
     137
     138and also the course itself vanished:
     139
     140    >>> list(fac['DEPT2'].courses)
     141    []
  • main/waeup.kofa/trunk/src/waeup/kofa/university/course.py

    r9826 r9828  
    8383
    8484    results = cat.searchResults(course_code=(code, code))
    85     # Only one certcourse per certificate is needed
    86     reduced_results = []
    87     for certcourse in results:
    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 delCertCourses
    93     for certcourse in reduced_results:
    94         cert = certcourse.__parent__
     85
     86    # remove each found referrer (certs might refer to same course multiple
     87    # times)
     88    certs = [x.__parent__ for x in results]
     89    unique_certs = list(set(certs))
     90    for cert in unique_certs:
    9591        cert.delCertCourses(code)
    9692    return
Note: See TracChangeset for help on using the changeset viewer.