Last change
on this file since 2091 was
1253,
checked in by Henrik Bettermann, 18 years ago
|
moved tool scripts to waeup_utilities
|
File size:
1.0 KB
|
Rev | Line | |
---|
[1253] | 1 | ##parameters=REQUEST, certid=None |
---|
| 2 | # $Id: refresh_certificate_info.py 1094 2006-12-19 12:11:44Z henrik $ |
---|
| 3 | """ |
---|
| 4 | refresh the certificate info in the students_catalog |
---|
| 5 | """ |
---|
| 6 | request = context.REQUEST |
---|
| 7 | if not certid: |
---|
| 8 | return "Certificate not specified" |
---|
| 9 | |
---|
| 10 | course = request.get('certid') |
---|
| 11 | res = context.portal_catalog(portal_type='Certificate',id = course) |
---|
| 12 | if not res: |
---|
| 13 | return "Certificate %s not found" |
---|
| 14 | c_brain = res[0] |
---|
| 15 | c_path = c_brain.getPath().split('/') |
---|
| 16 | faculty = c_path[-4] |
---|
| 17 | department = c_path[-3] |
---|
| 18 | s_cat = context.students_catalog |
---|
| 19 | s_res = s_cat(course = certid) |
---|
| 20 | #from Products.zdb import set_trace |
---|
| 21 | #set_trace() |
---|
| 22 | if not s_res: |
---|
| 23 | return "No students for %s not found" |
---|
| 24 | refreshed = [] |
---|
| 25 | refreshed.append("Record started") |
---|
| 26 | for 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) |
---|
| 33 | return '\r'.join(refreshed) |
---|
Note: See
TracBrowser for help on using the repository browser.