source: WAeUP_SRP/branches/joachim-azax-branch/skins/waeup_utilities/refresh_certificate_info.py @ 3147

Last change on this file since 3147 was 1253, checked in by Henrik Bettermann, 18 years ago

moved tool scripts to waeup_utilities

File size: 1.0 KB
Line 
1##parameters=REQUEST, certid=None
2# $Id: refresh_certificate_info.py 1094 2006-12-19 12:11:44Z henrik $
3"""
4refresh the certificate info in the students_catalog
5"""
6request = context.REQUEST
7if not certid:
8    return "Certificate not specified"
9
10course = request.get('certid')
11res = context.portal_catalog(portal_type='Certificate',id = course)
12if not res:
13    return "Certificate %s not found"
14c_brain = res[0]
15c_path = c_brain.getPath().split('/')
16faculty = c_path[-4]
17department = c_path[-3]
18s_cat = context.students_catalog
19s_res = s_cat(course = certid)
20#from Products.zdb import set_trace
21#set_trace()
22if not s_res:
23    return "No students for %s not found"
24refreshed = []
25refreshed.append("Record started")
26for student_id in [st.id  for st in s_res]:
27    s_cat.modifyRecord(id = student_id,
28                       course = course,
29                       faculty = faculty,
30                       department = department,
31                       )
32    refreshed.append("Record %s refreshed" % student_id)
33return '\r'.join(refreshed)
Note: See TracBrowser for help on using the repository browser.