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

Last change on this file was 2538, checked in by joachim, 17 years ago

redirect none SectionOfficers? to anonymous_view (in custom)

  • Property svn:keywords set to Id
File size: 3.0 KB
RevLine 
[1415]1##parameters=REQUEST
2# $Id: add_student.py 2538 2007-11-05 16:19:18Z joachim $
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
[1571]15logger = logging.getLogger('Skins.add_student')
[1415]16
[2538]17if mtool.isAnonymousUser() or not context.isSectionOfficer():
18    return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
19
[1415]20validate = REQUEST.has_key("cpsdocument_edit_button") and\
[1421]21           REQUEST.get("cpsdocument_edit_button").startswith('Add')
[1415]22d = {}
23mode = 'edit'
[2503]24rendered,psm,ds = lt.renderLayout(layout_id= 'add_student',
25                      schema_id= 'add_student',
[1415]26                      context=context,
27                      mapping=validate and REQUEST,
28                      ob=d,
29                      layout_mode=mode,
30                      commit = False
31                      )
32if psm == 'invalid':
33    psm = "Please correct your input."
34    return context.add_student_form(rendered = rendered,
35                                 psm = psm,
36                                 #psm = "%s, %s" % (psm,ds),
37                                 mode = mode,
38                                 formaction = "add_student",
[1420]39                                 button = "Add",
[1415]40                                 ds = ds,
41                                 )
42elif psm == '':
43    return context.add_student_form(rendered = rendered,
44                                 psm = psm,
45                                 mode = mode,
46                                 formaction = "add_student",
[1420]47                                 button = "Add",
[1415]48                                 ds = ds,
49                                 )
50elif psm == 'valid':
51    pass
[1416]52matric_no = ds.get('matric_no')
[1419]53if matric_no:
54    res = context.students_catalog(matric_no = matric_no)
55    if res:
56        psm = "Student with matric_no %s exists with Id: %s" % (matric_no,res[0].id)
57        return context.add_student_form(rendered = rendered,
[1416]58                                 psm = psm,
59                                 #psm = "%s, %s" % (psm,ds),
60                                 mode = mode,
61                                 formaction = "add_student",
[1420]62                                 button = "Add",
[1416]63                                 ds = ds,
64                                 )
[1415]65dict = {}
66dict.update(ds)
[1752]67sid,password = context.waeup_tool.addStudent(dict)
[1415]68dict['sid'] = sid
69dict['password'] = password
70student_rec = context.getFormattedStudentEntry(context.students_catalog(id = sid)[0])
[1422]71psm = "Student record with Id %s and Password %s has been created." % (sid,password)
[1571]72logger.info('%s created student %s' % (member,sid))
[1415]73return context.add_student_form(rendered = rendered,
74                                 mode = 'view',
75                                 psm = psm,
76                                 ds = dict,
77                                 student = student_rec,
78                                 )
79
80
Note: See TracBrowser for help on using the repository browser.