source: WAeUP_SRP/trunk_not_used/skins/waeup_student/course_edit.py @ 2484

Last change on this file since 2484 was 2053, checked in by Henrik Bettermann, 17 years ago

resolves ticket #318 point 1

File size: 2.5 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    try:
33        context.portal_workflow.doActionFor(context,'open')
34    except:
35        pass
36
37is_valid, ds = course_doc.validate(request=REQUEST,
38                                schema_id = 'student_course_result',
39                                layout_id = 'student_course_result_fe',
40                                proxy=context,
41                                use_session=True)
42
43psm = ""
44args = {}
45action = "/course_edit_form"
46base_url = context.absolute_url()
47
48if is_valid:
49    if cpsdocument_edit_button:
50        #name = "%(firstname)s %(middlename)s %(lastname)s" % ds
51        #name = name.strip()
52        #name = name.replace('  ',' ')
53        #email = ds.get('email')
54        #phone = ds.get('phone')
55        #student_id = context.getStudentId()
56        #context.students_catalog.modifyRecord(id = student_id,
57        #                                      name = name,
58        #                                      email = email,
59        #                                      phone = phone,
60        #                                      sex = ds.get('sex'),
61        #                                     )
62        logger.info('%s (%s) edited course result data %s' % (info['id'],info['review_state'],context.id))
63        #action = ""
64        #base_url = student.absolute_url()
65        #url = base_url + action
66        psm = 'psm_content_changed'
67else:
68    psm = 'psm_content_error'
69    args = getFormUidUrlArg(REQUEST)
70
71args['portal_status_message'] = psm
72url = base_url + action + '?' + urlencode(args)
73REQUEST.RESPONSE.redirect(url)
Note: See TracBrowser for help on using the repository browser.