source: waeup_product/trunk/skins/waeup_student/add_accommodation.py @ 104

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

=accommodationhall

  • Property svn:keywords set to Id
File size: 1.9 KB
Line 
1##parameters=REQUEST=None
2# $Id: add_accommodation.py 104 2005-10-27 16:10:11Z 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
18accofolder = getattr(context,"Accommodation",None)
19if accofolder is None:
20    context.invokeFactory('AccoFolder','Accommodation')
21    accofolder = getattr(context,"Accommodation")
22    context.notifyCPSDocumentCreation(ob=accofolder)
23   
24   
25res,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                      )
33if 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                                 )
39elif psm == '':
40    return context.common_edit_form(rendered = res,
41                                 create = 1,
42                                 type_name = type_name,
43                                 psm = psm,
44                                 )
45   
46elif psm == 'valid':
47    oid = "%s" % ds.get('heading').replace(' ','')
48    accofolder.invokeFactory(type_name,oid)
49    object = getattr(accofolder,oid)   
50    object.getContent().edit(mapping=ds)
51    context.notifyCPSDocumentCreation(ob=object)
52    psm = 'new %s created' % oid
53    context_ti = context.portal_types[context.portal_type]
54    index = context_ti.getActionById('view','university_view')
55    return getattr(context,index)(psm=psm)
56
Note: See TracBrowser for help on using the repository browser.