source: WAeUP_SRP/branches/srpp_branch/skins/waeup_student/register_level.py @ 7657

Last change on this file since 7657 was 188, checked in by Henrik Bettermann, 19 years ago

minor modifications

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