[1151] | 1 | ## Script (Python) "deleteAllCourses" |
---|
| 2 | ##bind container=container |
---|
| 3 | ##bind context=context |
---|
| 4 | ##bind namespace= |
---|
| 5 | ##bind script=script |
---|
| 6 | ##bind subpath=traverse_subpath |
---|
| 7 | ##parameters=matric_no=None |
---|
| 8 | ##title= |
---|
| 9 | ## |
---|
| 10 | # $Id: createStudentFT.py 1151 2006-12-29 22:05:53Z joachim $ |
---|
| 11 | ''' create the Studenbase folder''' |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | pm = context.portal_membership |
---|
| 15 | member = pm.getAuthenticatedMember() |
---|
| 16 | wftool = context.portal_workflow |
---|
| 17 | students_folder = context.portal_url.getPortalObject().campus.students |
---|
| 18 | import logging |
---|
| 19 | logger = logging.getLogger('createStudentFT') |
---|
| 20 | |
---|
| 21 | if str(member) not in ("henrik","joachim"): |
---|
| 22 | return "not possible" |
---|
| 23 | if not matric_no: |
---|
| 24 | return "No matric_no" |
---|
| 25 | |
---|
| 26 | if context.students_catalog(matric_no=matric_no): |
---|
| 27 | return "Student with %s already exists" % matric_no |
---|
| 28 | res = context.returning_import(matric_no = matric_no) |
---|
| 29 | if len(res) != 1: |
---|
| 30 | return "Matricel No %s not found in Returning Table" % matric_no |
---|
| 31 | student_brain = res[0] |
---|
| 32 | sid = context.waeup_tool.generateStudentId(student_brain.Lastname[0]) |
---|
| 33 | students_folder.invokeFactory('Student', sid) |
---|
| 34 | logger.info('"%s","Created Student","%s", "%s" ' % (member,sid,matric_no)) |
---|
| 35 | student = getattr(students_folder,sid) |
---|
| 36 | wftool.doActionFor(student,'clear_and_validate') |
---|
| 37 | student.manage_setLocalRoles(sid, ['Owner',]) |
---|
| 38 | context.students_catalog.addRecord(id = sid, |
---|
| 39 | matric_no = matric_no, |
---|
| 40 | jamb_reg_no = student_brain.Entryregno, |
---|
| 41 | sex = student_brain.Sex == "F", |
---|
| 42 | name = "%s %s %s" % (student_brain.Firstname, |
---|
| 43 | student_brain.Middlename, |
---|
| 44 | student_brain.Lastname) |
---|
| 45 | ) |
---|
| 46 | return "Student MatricelNo %s and %s created" % (matric_no,sid) |
---|
| 47 | |
---|