source: WAeUP_SRP/trunk/skins/waeup_student/add_course_ticket.py @ 453

Last change on this file since 453 was 404, checked in by joachim, 18 years ago

accommodation startet

  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1##parameters=REQUEST
2# $Id: add_course_ticket.py 404 2006-08-22 21:45:50Z joachim $
3"""
4add a course_ticket
5"""
6type_name = 'CourseTicket'
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 = 'add_course_ticket',
25                      )
26if True or psm == 'invalid':
27    return context.common_edit_form(rendered = res,
28                                 create = 1,
29                                 type_name = type_name,
30                                 psm = 'Not yet active',
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    psm = (ds)
43    oid = ds.get('Title')
44    if hasattr(context,oid):
45        return context.common_edit_form(rendered = res,
46                                 create = 1,
47                                 type_name = type_name,
48                                 psm = 'You already registered for that level',
49                                 )
50    context.invokeFactory(type_name,oid)
51    object = getattr(context,oid)
52    voc = pv.courselevel
53    ds.set('Title',voc.get(oid))
54    object.getContent().edit(mapping=ds,proxy=object)
55    context.notifyCPSDocumentCreation(ob=object)
56    psm = 'new %s created' % oid
57    semester_id = 'Semester_1_%s_%s' % (oid,context.getId())
58    object.invokeFactory('Semester',semester_id)
59    semester = getattr(object,semester_id)
60    semester.getContent().edit(mapping={'Title': 'First Semester'})
61    semester_id = 'Semester_2_%s_%s' % (oid,context.getId())
62    object.invokeFactory('Semester',semester_id)
63    semester = getattr(object,semester_id)
64    semester.getContent().edit(mapping={'Title': 'Second Semester'})
65    context_ti = context.portal_types[context.portal_type]
66    index = context_ti.getActionById('view','university_view')
67    return getattr(context,index)(psm=psm)
Note: See TracBrowser for help on using the repository browser.