##parameters=REQUEST # $Id: add_student.py 1421 2007-02-15 12:56:10Z henrik $ """ process the the accommodation reservation """ import DateTime current = DateTime.DateTime() pr = context.portal_registration wftool = context.portal_workflow lt = context.portal_layouts mtool = context.portal_membership member = mtool.getAuthenticatedMember() acco_cat = context.portal_accommodation import logging logger = logging.getLogger('Student.Add') validate = REQUEST.has_key("cpsdocument_edit_button") and\ REQUEST.get("cpsdocument_edit_button").startswith('Add') d = {} mode = 'edit' rendered,psm,ds = lt.renderLayout(layout_id= 'student_create', schema_id= 'student_create', context=context, mapping=validate and REQUEST, ob=d, layout_mode=mode, commit = False ) if psm == 'invalid': psm = "Please correct your input." return context.add_student_form(rendered = rendered, psm = psm, #psm = "%s, %s" % (psm,ds), mode = mode, formaction = "add_student", button = "Add", ds = ds, ) elif psm == '': return context.add_student_form(rendered = rendered, psm = psm, mode = mode, formaction = "add_student", button = "Add", ds = ds, ) elif psm == 'valid': pass matric_no = ds.get('matric_no') if matric_no: res = context.students_catalog(matric_no = matric_no) if res: psm = "Student with matric_no %s exists with Id: %s" % (matric_no,res[0].id) return context.add_student_form(rendered = rendered, psm = psm, #psm = "%s, %s" % (psm,ds), mode = mode, formaction = "add_student", button = "Add", ds = ds, ) dict = {} dict.update(ds) sid,password = context.waeup_tool.createStudent(dict) dict['sid'] = sid dict['password'] = password student_rec = context.getFormattedStudentEntry(context.students_catalog(id = sid)[0]) psm = "Student with Id %s and Password %s created!" % (sid,password) logger.info('"%s","created student","%s"' % (member,sid)) return context.add_student_form(rendered = rendered, #psm = "%s, %s" % (psm,ds), mode = 'view', psm = psm, ds = dict, student = student_rec, )