[96] | 1 | ##parameters=REQUEST=None |
---|
| 2 | # $Id: create_common.py 892 2006-11-18 21:14:18Z henrik $ |
---|
| 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(), |
---|
[290] | 18 | schema_id= type_name.lower(), |
---|
[96] | 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, |
---|
[892] | 28 | psm = 'Please correct your errors!', |
---|
[96] | 29 | ) |
---|
| 30 | elif psm == '': |
---|
| 31 | return context.common_edit_form(rendered = res, |
---|
| 32 | create = 1, |
---|
| 33 | type_name = type_name, |
---|
| 34 | psm = psm, |
---|
| 35 | ) |
---|
[892] | 36 | |
---|
[96] | 37 | elif psm == 'valid': |
---|
| 38 | oid = "%s" % ds.get('Title').replace(' ','') |
---|
[892] | 39 | context.invokeFactory(type_name,oid) |
---|
| 40 | object = getattr(context,oid) |
---|
[96] | 41 | object.getContent().edit(mapping=ds) |
---|
[103] | 42 | context.notifyCPSDocumentCreation(ob=object) |
---|
[892] | 43 | psm = 'new %s created!' % oid |
---|
| 44 | context_ti = context.portal_types[context.portal_type] |
---|
[96] | 45 | index = context_ti.getActionById('view','university_view') |
---|
| 46 | return getattr(context,index)(psm=psm) |
---|
| 47 | |
---|