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

Last change on this file since 9819 was 120, checked in by Henrik Bettermann, 19 years ago
File size: 1.9 KB
Line 
1##parameters=REQUEST=None
2# $Id: add_accommodation.py 107 2005-10-27 23:58:38Z 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                                 )
45elif 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
Note: See TracBrowser for help on using the repository browser.