- Timestamp:
- 26 Nov 2011, 09:35:46 (13 years ago)
- Location:
- main/waeup.sirp/trunk/src/waeup/sirp
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.sirp/trunk/src/waeup/sirp/students/interfaces.py
r7203 r7209 248 248 source = CertificateSource(), 249 249 default = None, 250 required = True,250 required = False, 251 251 ) 252 252 -
main/waeup.sirp/trunk/src/waeup/sirp/university/certificate.py
r7207 r7209 19 19 """ 20 20 import grok 21 from zope.event import notify 21 22 from zope.catalog.interfaces import ICatalog 22 23 from zope.component import getUtility … … 113 114 def getInterfaces(self): 114 115 return implementedBy(CertificateCourse) 116 117 @grok.subscribe(ICertificate, grok.IObjectRemovedEvent) 118 def handle_certificate_removed(certificate, event): 119 """If a certificate is deleted, we make sure that also referrers to 120 student studycourse objects are removed. 121 """ 122 code = certificate.code 123 124 # Find all student studycourses that refer to given certificate... 125 try: 126 cat = getUtility(ICatalog, name='students_catalog') 127 except ComponentLookupError: 128 # catalog not available. This might happen during tests. 129 return 130 131 results = cat.searchResults(certcode=(code, code)) 132 for student in results: 133 # Remove that referrer... 134 studycourse = student['studycourse'] 135 studycourse.certificate = None 136 notify(grok.ObjectModifiedEvent(student)) 137 event_name = event.__implemented__.__name__.replace( 138 'zope.lifecycleevent.','') 139 student.loggerInfo(event_name, 'removed: certificate') 140 return
Note: See TracChangeset for help on using the changeset viewer.