source: WAeUP_SRP/trunk/skins/waeup_student/add_student.py @ 1668

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

new logging format Part 4 (rest)

  • Property svn:keywords set to Id
File size: 2.9 KB
Line 
1##parameters=REQUEST
2# $Id: add_student.py 1571 2007-03-17 15:25:56Z henrik $
3"""
4process the the accommodation reservation
5"""
6import DateTime
7current = DateTime.DateTime()
8pr = context.portal_registration
9wftool = context.portal_workflow
10lt = context.portal_layouts
11mtool = context.portal_membership
12member = mtool.getAuthenticatedMember()
13acco_cat = context.portal_accommodation
14import logging
15logger = logging.getLogger('Skins.add_student')
16
17validate = REQUEST.has_key("cpsdocument_edit_button") and\
18           REQUEST.get("cpsdocument_edit_button").startswith('Add')
19d = {}
20mode = 'edit'
21rendered,psm,ds = lt.renderLayout(layout_id= 'student_create',
22                      schema_id= 'student_create',
23                      context=context,
24                      mapping=validate and REQUEST,
25                      ob=d,
26                      layout_mode=mode,
27                      commit = False
28                      )
29if psm == 'invalid':
30    psm = "Please correct your input."
31    return context.add_student_form(rendered = rendered,
32                                 psm = psm,
33                                 #psm = "%s, %s" % (psm,ds),
34                                 mode = mode,
35                                 formaction = "add_student",
36                                 button = "Add",
37                                 ds = ds,
38                                 )
39elif psm == '':
40    return context.add_student_form(rendered = rendered,
41                                 psm = psm,
42                                 mode = mode,
43                                 formaction = "add_student",
44                                 button = "Add",
45                                 ds = ds,
46                                 )
47elif psm == 'valid':
48    pass
49matric_no = ds.get('matric_no')
50if matric_no:
51    res = context.students_catalog(matric_no = matric_no)
52    if res:
53        psm = "Student with matric_no %s exists with Id: %s" % (matric_no,res[0].id)
54        return context.add_student_form(rendered = rendered,
55                                 psm = psm,
56                                 #psm = "%s, %s" % (psm,ds),
57                                 mode = mode,
58                                 formaction = "add_student",
59                                 button = "Add",
60                                 ds = ds,
61                                 )
62dict = {}
63dict.update(ds)
64sid,password = context.waeup_tool.createStudent(dict)
65dict['sid'] = sid
66dict['password'] = password
67student_rec = context.getFormattedStudentEntry(context.students_catalog(id = sid)[0])
68psm = "Student record with Id %s and Password %s has been created." % (sid,password)
69logger.info('%s created student %s' % (member,sid))
70return context.add_student_form(rendered = rendered,
71                                 #psm = "%s, %s" % (psm,ds),
72                                 mode = 'view',
73                                 psm = psm,
74                                 ds = dict,
75                                 student = student_rec,
76                                 )
77
78
Note: See TracBrowser for help on using the repository browser.