Changeset 9227 for main


Ignore:
Timestamp:
23 Sep 2012, 12:23:42 (12 years ago)
Author:
Henrik Bettermann
Message:

If a former course attribute is set, we make sure that referrers in a
certificatescontainer are removed.

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

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py

    r9217 r9227  
    236236            'code,local_roles,title,title_prefix\r\n')
    237237        return
     238
     239class SupplementaryBrowserTests(UniversitySetup):
     240    # These are additional tests to browser.txt
     241
     242    def test_set_former_course(self):
     243        # A certificate course will be automatically removed when
     244        # the former_course attribute of the corresponding course is set.
     245        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     246        self.assertTrue(self.app['faculties']['fac1']['dep1'].certificates[
     247            'CERT1'].has_key('COURSE1_100'))
     248        self.browser.open('http://localhost/app/faculties/fac1/dep1/courses/COURSE1/manage')
     249        self.browser.getControl(name="form.former_course").value = ['selected']
     250        self.browser.getControl("Save").click()
     251        self.assertFalse(self.app['faculties']['fac1']['dep1'].certificates[
     252            'CERT1'].has_key('COURSE1_100'))
     253        return
     254
     255    def test_remove_course(self):
     256        # A certificate course will be automatically removed when
     257        # the corresponding course is removed.
     258        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     259        self.assertTrue(self.app['faculties']['fac1']['dep1'].certificates[
     260            'CERT1'].has_key('COURSE1_100'))
     261        self.browser.open('http://localhost/app/faculties/fac1/dep1/manage')
     262        ctrl = self.browser.getControl(name='val_id')
     263        ctrl.getControl(value='COURSE1').selected = True
     264        self.browser.getControl("Remove selected", index=0).click()
     265        self.assertFalse(self.app['faculties']['fac1']['dep1'].certificates[
     266            'CERT1'].has_key('COURSE1_100'))
     267        return
  • main/waeup.kofa/trunk/src/waeup/kofa/university/course.py

    r9220 r9227  
    9090    return
    9191
     92@grok.subscribe(ICourse, grok.IObjectModifiedEvent)
     93def handle_set_former_course(course, event):
     94    """If a former course attribute is set, we make sure that referrers in a
     95       certificatescontainer are removed.
     96    """
     97    if event.object.former_course:
     98        handle_course_removed(course, event)
     99    return
     100
    92101class CoursesPlugin(grok.GlobalUtility):
    93102    """A plugin that updates courses.
Note: See TracChangeset for help on using the changeset viewer.