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

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

=clearence + eligibility added

  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1##parameters=REQUEST
2# $Id: register_level.py 164 2005-11-10 21:40:01Z 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 = str(ds),
31                                 #psm = 'Please correct your errors',
32                                 )
33elif psm == '':
34    return context.common_edit_form(rendered = res,
35                                 create = 1,
36                                 type_name = type_name,
37                                 psm = psm,
38                                 #psm = str(ds),
39                                 )
40   
41elif psm == 'valid':
42    voc = pv.courselevel
43    level_id = voc.items()[0][0]
44    level = getattr(context,level_id,None)
45    if level:
46        return context.common_edit_form(rendered = res,
47                                 create = 1,
48                                 type_name = type_name,
49                                 psm = "You have already registered for Level %s" % voc.get(level_id)
50                                 )
51   
52    context.invokeFactory(type_name,level_id)
53    object = getattr(context,level_id)
54    ds.set('Title',voc.get(level_id))
55    object.getContent().edit(mapping=ds,proxy=object)
56    context.notifyCPSDocumentCreation(ob=object)
57    psm = 'new %s created' % level_id
58    semester_id = 'Semester_1_%s_%s' % (level_id,context.getId())
59    object.invokeFactory('Semester',semester_id)
60    semester = getattr(object,semester_id)
61    semester.getContent().edit(mapping={'Title': 'First Semester'})
62    semester_id = 'Semester_2_%s_%s' % (level_id,context.getId())
63    object.invokeFactory('Semester',semester_id)
64    semester = getattr(object,semester_id)
65    semester.getContent().edit(mapping={'Title': 'Second Semester'})
66    context_ti = context.portal_types[context.portal_type]
67    index = context_ti.getActionById('view','university_view')
68    return getattr(context,index)(psm=psm)
Note: See TracBrowser for help on using the repository browser.