source: WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py @ 1032

Last change on this file since 1032 was 1025, checked in by joachim, 18 years ago

Removed all fields except study_course from student_study_course
adde StudyCourse? Widget
M profiles/default/layouts/student_study_course.xml
M skins/waeup_default/waeup_edit.py
M Widgets.py
catch unauthorised errors
M skins/waeup_student/application_edit_form.pt
M skins/waeup_student/getStudentInfo.py
M skins/waeup_student/study_course_view.pt
AM skins/waeup_student/getStudentId.py

File size: 2.5 KB
Line 
1##parameters=REQUEST, cluster=None, cpsdocument_edit_and_view_button=None, came_from=None
2# $Id: external_edit.py 805 2006-11-09 09:38:29Z joachim $
3"""
4Called when a document form is posted.
5
6Validates data, then:
7
8 - if there's no error, updates the object and redirects to it,
9
10 - if there's an error, puts data in session and redirects to edit form.
11
12A form uid is propagated during the redirect to uniquely identify the
13form in the session.
14"""
15
16from urllib import urlencode
17from Products.CPSDocument.utils import getFormUidUrlArg
18
19# Check flexible controls
20#context.editLayouts(REQUEST=REQUEST)
21
22# Validate the document and write it if it's valid
23# (We don't call getEditableContent here, validate does it when needed.)
24doc = context.getContent()
25if context.portal_type == "StudentStudyCourse":
26    if len(context.objectIds()) > 0:
27        psm = 'Edit of StudyCourse is only possible if there are no levels'
28        args = getFormUidUrlArg(REQUEST)
29        args['portal_status_message'] = psm
30        url = context.absolute_url() + '?' + urlencode(args)
31        REQUEST.RESPONSE.redirect(url)
32       
33is_valid, ds = doc.validate(request=REQUEST, proxy=context, cluster=cluster,
34                            use_session=True)
35
36##if action is None:
37##    ti = doc.getTypeInfo()
38##    action = ti.queryMethodID('edit', 'external_edit_form')
39##    action = '/' + action
40
41action = "/" + came_from
42
43if is_valid:
44    comments = REQUEST.get('comments')
45    context.cpsdocument_notify_modification(comments=comments)
46    if context.portal_type == "StudentStudyCourse":
47        course = ds.get('study_course')
48        student_id = context.getStudentId()
49        res = context.portal_catalog(portal_type='Certificate',id = course)
50        if res:
51            c_brain = res[0]
52            c_path = c_brain.getPath().split('/')
53            student_id = context.getStudentId()
54            context.students_catalog.modifyRecord(id = student_id,
55                                                  course = course,
56                                                  faculty = c_path[-4],
57                                                  department = c_path[-3],
58                                                  )
59    if cpsdocument_edit_and_view_button is not None:
60        action = ''
61    psm = 'psm_content_changed'
62    args = {}
63else:
64    psm = 'psm_content_error'
65    args = getFormUidUrlArg(REQUEST)
66
67args['portal_status_message'] = psm
68url = context.absolute_url() + action + '?' + urlencode(args)
69REQUEST.RESPONSE.redirect(url)
70
Note: See TracBrowser for help on using the repository browser.