source: WAeUP_SRP/branches/srpp_branch/skins/waeup_student/create_jamb.py @ 2234

Last change on this file since 2234 was 173, checked in by joachim, 19 years ago

=added Faculties and Departments in install + other cosmetics

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1##parameters=REQUEST=None
2# $Id: create_jamb.py 173 2005-11-15 16:28:29Z 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':
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    skw = {'title': "%(firstname)s %(lastname)s" % ds}
40    context.invokeFactory('Student',s_id)
41    student = getattr(context,s_id)   
42    student.getContent().edit(mapping=skw)
43    context.notifyCPSDocumentCreation(ob=student)
44    jamb_id = 'JAMB'
45    student.invokeFactory('Jamb',jamb_id)
46    jamb = getattr(student,jamb_id)   
47    ds.set('title', "%(reg_nr)s (%(lastname)s)" % ds)
48    jamb.getContent().edit(mapping=ds)
49    context.notifyCPSDocumentCreation(ob=jamb)
50    psm = 'Student created'
51    noCPSMember = False
52    try:
53        #pr.addMember(s_id, 'UnSeT',roles=('Member','CPSMember','Student','Contributor'))
54        pr.addMember(s_id, '123456',roles=('Member','CPSMember','Student','Contributor'))
55    except:
56        noCPSMember = True
57    if noCPSMember:
58        #pr.addMember(s_id, 'UnSeT',roles=('Member','Student','Contributor'))
59        pr.addMember(s_id, '123456',roles=('Member','Student','Contributor'))
60    student.manage_setLocalRoles(s_id, ['Owner'])
61    jamb.manage_setLocalRoles(s_id, ['Owner'])
62##    student.getContent().setOwnership(s_id)
63##    jamb.getContent().setOwnership(s_id)
64##    groups = context.portal_directories.groups
65##    gm = list(groups.getEntry('Students')['members'])
66##    gm.extend((s_id,))
67##    groups.editEntry({'group': 'Students',
68##                      'members': gm}) 
69    return context.students_folder_view_manager(psm=psm)
70
Note: See TracBrowser for help on using the repository browser.