source: WAeUP_SRP/branches/joachim-azax-branch/skins/waeup_student/course_edit.py @ 11154

Last change on this file since 11154 was 1864, checked in by joachim, 17 years ago

open if closed

File size: 2.4 KB
Line 
1## Script (Python) "course_edit"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=REQUEST, cpsdocument_edit_button=None, cpsdocument_edit_and_view_button=None, action=None
8##title=
9# $Id: course_edit.py 1071 2006-12-16 15:53:13Z joachim $
10"""
11"""
12wf = context.portal_workflow
13from urllib import urlencode
14from Products.CPSDocument.utils import getFormUidUrlArg
15import DateTime
16current = DateTime.DateTime()
17import logging
18logger = logging.getLogger('Skins.course_edit')
19
20info = context.getCourseResultInfo()
21
22if info is None:
23    logger.info('Anonymous user tried to access %s' % REQUEST.get('URL0'))
24    return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
25
26student = info['student']
27#per = info['per']
28course_doc = info['course_doc']
29state = info['review_state']
30result_state = wf.getInfoFor(context,'review_state',None)
31if result_state == "closed":
32    context.portal_workflow.doActionFor(context,'open')
33
34is_valid, ds = course_doc.validate(request=REQUEST,
35                                schema_id = 'student_course_result',
36                                layout_id = 'student_course_result_fe',
37                                proxy=context,
38                                use_session=True)
39
40psm = ""
41args = {}
42action = "/course_edit_form"
43base_url = context.absolute_url()
44
45if is_valid:
46    if cpsdocument_edit_button:
47        #name = "%(firstname)s %(middlename)s %(lastname)s" % ds
48        #name = name.strip()
49        #name = name.replace('  ',' ')
50        #email = ds.get('email')
51        #phone = ds.get('phone')
52        #student_id = context.getStudentId()
53        #context.students_catalog.modifyRecord(id = student_id,
54        #                                      name = name,
55        #                                      email = email,
56        #                                      phone = phone,
57        #                                      sex = ds.get('sex'),
58        #                                     )
59        logger.info('%s (%s) edited course result data %s' % (info['id'],info['review_state'],context.id))
60        #action = ""
61        #base_url = student.absolute_url()
62        #url = base_url + action
63        psm = 'psm_content_changed'
64else:
65    psm = 'psm_content_error'
66    args = getFormUidUrlArg(REQUEST)
67
68args['portal_status_message'] = psm
69url = base_url + action + '?' + urlencode(args)
70REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.