1 | ##parameters=REQUEST=None |
---|
2 | # $Id: create_course.py 103 2005-10-27 16:06:03Z joachim $ |
---|
3 | """ |
---|
4 | Create a Faculty |
---|
5 | |
---|
6 | """ |
---|
7 | type_name = 'Course' |
---|
8 | REQUEST.set('type_name',type_name) |
---|
9 | |
---|
10 | ti = context.portal_types[type_name] |
---|
11 | pr = context.portal_registration |
---|
12 | pm = context.portal_membership |
---|
13 | |
---|
14 | validate = REQUEST.has_key("cpsdocument_create_button") |
---|
15 | |
---|
16 | lt = context.portal_layouts |
---|
17 | |
---|
18 | res,psm,ds = lt.renderLayout(layout_id= 'course', |
---|
19 | schema_id = 'course', |
---|
20 | context=context, |
---|
21 | mapping=validate and REQUEST, |
---|
22 | ob={}, |
---|
23 | layout_mode='create', |
---|
24 | create_action = 'create_course', |
---|
25 | ) |
---|
26 | if psm == 'invalid': |
---|
27 | return context.common_edit_form(rendered = res, |
---|
28 | create = 1, |
---|
29 | type_name = type_name, |
---|
30 | psm = 'Please correct your errors', |
---|
31 | ) |
---|
32 | elif psm == '': |
---|
33 | return context.common_edit_form(rendered = res, |
---|
34 | create = 1, |
---|
35 | type_name = type_name, |
---|
36 | psm = psm, |
---|
37 | ) |
---|
38 | |
---|
39 | elif psm == 'valid': |
---|
40 | oid = "%s" % ds.get('code').replace(' ','') |
---|
41 | context.invokeFactory(type_name,oid) |
---|
42 | object = getattr(context,oid) |
---|
43 | object.getContent().edit(mapping=ds,proxy=object) |
---|
44 | context.notifyCPSDocumentCreation(ob=object) |
---|
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 | |
---|