source: waeup_product/trunk/skins/waeup_student/register_level.py @ 182

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

=post-primary results adding

  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1##parameters=REQUEST
2# $Id: register_level.py 179 2005-11-16 16:44:13Z joachim $
3"""
4register for next level
5"""
6type_name = 'StudyLevel'
7ti = context.portal_types[type_name]
8pm = context.portal_membership
9REQUEST.set('type_name',type_name)
10
11validate = REQUEST.has_key("cpsdocument_create_button")
12
13
14lt = context.portal_layouts
15pv = context.portal_vocabularies
16#pr = context.portal_registration
17
18res,psm,ds = lt.renderLayout(layout_id= 'study_level',
19                      schema_id= 'study_level',
20                      context=context,
21                      mapping=validate and REQUEST,
22                      ob={},
23                      layout_mode='create',
24                      create_action = 'register_level',
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                                 )
38   
39elif psm == 'valid':
40    voc = pv.courselevel
41    level_id = voc.items()[0][0]
42    level = getattr(context,level_id,None)
43    if level:
44        return context.common_edit_form(rendered = res,
45                                 create = 1,
46                                 type_name = type_name,
47                                 psm = "You have already registered for Level %s" % voc.get(level_id)
48                                 )
49   
50    context.invokeFactory(type_name,level_id)
51    object = getattr(context,level_id)
52    ds.set('Title',voc.get(level_id))
53    object.getContent().edit(mapping=ds,proxy=object)
54    context.notifyCPSDocumentCreation(ob=object)
55    psm = 'new %s created' % level_id
56    semester_id = 'Semester_1_%s_%s' % (level_id,context.getId())
57    object.invokeFactory('Semester',semester_id)
58    semester = getattr(object,semester_id)
59    semester.getContent().edit(mapping={'Title': 'First Semester'})
60    semester_id = 'Semester_2_%s_%s' % (level_id,context.getId())
61    object.invokeFactory('Semester',semester_id)
62    semester = getattr(object,semester_id)
63    semester.getContent().edit(mapping={'Title': 'Second Semester'})
64    context_ti = context.portal_types[context.portal_type]
65    index = context_ti.getActionById('view','university_view')
66    return getattr(context,index)(psm=psm)
Note: See TracBrowser for help on using the repository browser.