1 | ##parameters=REQUEST=None |
---|
2 | # $Id: create_common.py 96 2005-10-27 06:51:08Z joachim $ |
---|
3 | """ |
---|
4 | Create a Faculty |
---|
5 | |
---|
6 | """ |
---|
7 | type_name = REQUEST.get('type_name') |
---|
8 | |
---|
9 | ti = context.portal_types[type_name] |
---|
10 | pr = context.portal_registration |
---|
11 | pm = context.portal_membership |
---|
12 | |
---|
13 | validate = REQUEST.has_key("cpsdocument_create_button") |
---|
14 | |
---|
15 | lt = context.portal_layouts |
---|
16 | |
---|
17 | res,psm,ds = lt.renderLayout(layout_id= type_name.lower(), |
---|
18 | schema_id= 'metadata', |
---|
19 | context=context, |
---|
20 | mapping=validate and REQUEST, |
---|
21 | ob={}, |
---|
22 | layout_mode='create', |
---|
23 | ) |
---|
24 | if psm == 'invalid': |
---|
25 | return context.common_edit_form(rendered = res, |
---|
26 | create = 1, |
---|
27 | type_name = type_name, |
---|
28 | psm = 'Please correct your errors', |
---|
29 | ) |
---|
30 | elif psm == '': |
---|
31 | return context.common_edit_form(rendered = res, |
---|
32 | create = 1, |
---|
33 | type_name = type_name, |
---|
34 | psm = psm, |
---|
35 | ) |
---|
36 | |
---|
37 | elif psm == 'valid': |
---|
38 | oid = "%s" % ds.get('Title').replace(' ','') |
---|
39 | context.invokeFactory(type_name,oid) |
---|
40 | object = getattr(context,oid) |
---|
41 | okw = {'Title': ds.get('Title'), |
---|
42 | 'Description': ds.get('Description') |
---|
43 | } |
---|
44 | object.getContent().edit(mapping=ds) |
---|
45 | psm = 'new %s created' % oid |
---|
46 | context_ti = context.portal_types[context.portal_type] |
---|
47 | index = context_ti.getActionById('view','university_view') |
---|
48 | return getattr(context,index)(psm=psm) |
---|
49 | name = ds.get('name') |
---|
50 | student = getattr(context,s_id) |
---|
51 | student.edit(mapping=skw) |
---|
52 | context.notifyCPSDocumentCreation(ob=student) |
---|
53 | jamb_id = 'JAMB' |
---|
54 | student.invokeFactory('Jamb',jamb_id) |
---|
55 | jamb = getattr(student,jamb_id) |
---|
56 | ds.set('title', name) |
---|
57 | jamb.edit(mapping=ds) |
---|
58 | context.notifyCPSDocumentCreation(ob=jamb) |
---|
59 | psm = 'Student created' |
---|
60 | noCPSMember = False |
---|
61 | try: |
---|
62 | pr.addMember(s_id, 'UnSeT',roles=('Member','CPSMember','Student')) |
---|
63 | except: |
---|
64 | noCPSMember = True |
---|
65 | if noCPSMember: |
---|
66 | pr.addMember(s_id, 'UnSeT',roles=('Member',)) |
---|
67 | ## groups = context.portal_directories.groups |
---|
68 | ## gm = list(groups.getEntry('Students')['members']) |
---|
69 | ## gm.extend((s_id,)) |
---|
70 | ## groups.editEntry({'group': 'Students', |
---|
71 | ## 'members': gm}) |
---|
72 | ## return context.create_jamb_form(rendered = res, |
---|
73 | ## psm = psm, |
---|
74 | ## ds = ds, |
---|
75 | ## ) |
---|
76 | |
---|
77 | return res,psm,ds |
---|
78 | |
---|