source: WAeUP_SRP/branches/srpp_branch/skins/waeup_student/add_accommodation.py @ 4049

Last change on this file since 4049 was 145, checked in by joachim, 19 years ago

=fixed Title bug in Course and Hall

  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1##parameters=REQUEST=None
2# $Id: add_accommodation.py 145 2005-11-03 08:53:17Z joachim $
3"""
4Add a Accommodation Hall
5
6"""
7type_name = 'Accommodation'
8REQUEST.set('type_name',type_name)
9
10ti = context.portal_types[type_name]
11pr = context.portal_registration
12pm = context.portal_membership
13
14validate = REQUEST.has_key("cpsdocument_create_button")
15
16lt = context.portal_layouts
17
18res,psm,ds = lt.renderLayout(layout_id= 'accommodation',
19                      schema_id = 'accommodation',
20                      context=context,
21                      mapping=validate and REQUEST,
22                      ob={},
23                      layout_mode='create',
24                      create_action = 'add_accommodation',
25                      )
26if 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                                 )
32elif psm == '':
33    return context.common_edit_form(rendered = res,
34                                 create = 1,
35                                 type_name = type_name,
36                                 psm = psm,
37                                 )
38elif psm == 'valid':
39    oid = "%s" % ds.get('heading').replace(' ','')
40    context.invokeFactory(type_name,oid)
41    object = getattr(context,oid)
42    ds.set('Title',ds.get('heading'))
43    object.getContent().edit(mapping=ds)
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
Note: See TracBrowser for help on using the repository browser.