source: waeup_product/trunk/skins/waeup_student/create_jamb.py @ 54

Last change on this file since 54 was 53, checked in by joachim, 19 years ago

=more

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1##parameters=REQUEST=None
2# $Id: create_jamb.py 53 2005-10-17 08:06:46Z joachim $
3"""
4Create an the Jamb-Record for a Student
5
6"""
7
8type_name = 'Jamb'
9ti = context.portal_types[type_name]
10pr = context.portal_registration
11pm = context.portal_membership
12
13REQUEST.set('type_name',type_name)
14
15validate = REQUEST.has_key("cpsdocument_edit_button")
16
17lt = context.portal_layouts
18
19res,psm,ds = lt.renderLayout(layout_id= 'jambcreate',
20                      schema_id= 'jamb',
21                      context=context,
22                      mapping=validate and REQUEST,
23                      ob={},
24                      layout_mode='create',
25                      )
26if psm == 'invalid' or psm == '':
27    return context.create_jamb_form(rendered = res,
28                                 psm = 'Please correct your errors',
29                                 ds = ds,
30                                 )
31elif psm == '':
32    return context.create_jamb_form(rendered = res,
33                                 psm = psm,
34                                 ds = ds,
35                                 )
36   
37elif psm == 'valid':
38    s_id = "s%s" % ds.get('reg_nr')
39    name = ds.get('name')
40    skw = {'title': name}
41    context.invokeFactory('Student',s_id)
42    student = getattr(context,s_id)   
43    student.edit(mapping=skw)
44    context.notifyCPSDocumentCreation(ob=student)
45    jamb_id = 'JAMB'
46    student.invokeFactory('Jamb',jamb_id)
47    jamb = getattr(student,jamb_id)   
48    ds.set('title', name)
49    jamb.edit(mapping=ds)
50    context.notifyCPSDocumentCreation(ob=jamb)
51    psm = 'Student created'
52    pr.addMember(s_id, 'UnSeT',roles=('Member','CPSMember'))
53    groups = context.portal_directories.groups
54    gm = list(groups.getEntry('Students')['members'])
55    gm.extend((s_id,))
56    groups.editEntry({'group': 'Students',
57                      'members': gm}) 
58    return context.student_folder_view(psm=psm)
59##    return context.create_jamb_form(rendered = res,
60##                                 psm = psm,
61##                                 ds = ds,
62##                                 )
63   
64return res,psm,ds
65
Note: See TracBrowser for help on using the repository browser.