1 | ##parameters=REQUEST=None |
---|
2 | # $Id: add_accommodation.py 107 2005-10-27 23:58:38Z joachim $ |
---|
3 | """ |
---|
4 | Add a Accommodation Hall |
---|
5 | |
---|
6 | """ |
---|
7 | type_name = 'Accommodation' |
---|
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 | accofolder = getattr(context,"Accommodation",None) |
---|
19 | if accofolder is None: |
---|
20 | context.invokeFactory('AccoFolder','Accommodation') |
---|
21 | accofolder = getattr(context,"Accommodation") |
---|
22 | context.notifyCPSDocumentCreation(ob=accofolder) |
---|
23 | |
---|
24 | |
---|
25 | res,psm,ds = lt.renderLayout(layout_id= 'accommodation', |
---|
26 | schema_id = 'accommodation', |
---|
27 | context=context, |
---|
28 | mapping=validate and REQUEST, |
---|
29 | ob={}, |
---|
30 | layout_mode='create', |
---|
31 | create_action = 'add_accommodation', |
---|
32 | ) |
---|
33 | if psm == 'invalid': |
---|
34 | return context.common_edit_form(rendered = res, |
---|
35 | create = 1, |
---|
36 | type_name = type_name, |
---|
37 | psm = 'Please correct your errors', |
---|
38 | ) |
---|
39 | elif psm == '': |
---|
40 | return context.common_edit_form(rendered = res, |
---|
41 | create = 1, |
---|
42 | type_name = type_name, |
---|
43 | psm = psm, |
---|
44 | ) |
---|
45 | elif psm == 'valid': |
---|
46 | oid = "%s" % ds.get('heading').replace(' ','') |
---|
47 | accofolder.invokeFactory(type_name,oid) |
---|
48 | object = getattr(accofolder,oid) |
---|
49 | object.getContent().edit(mapping=ds) |
---|
50 | context.notifyCPSDocumentCreation(ob=object) |
---|
51 | psm = 'new %s created' % oid |
---|
52 | context_ti = context.portal_types[context.portal_type] |
---|
53 | index = context_ti.getActionById('view','university_view') |
---|
54 | return getattr(context,index)(psm=psm) |
---|
55 | |
---|