[1457] | 1 | ## Script (Python) "personal_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: application_edit.py 1071 2006-12-16 15:53:13Z joachim $ |
---|
| 10 | """ |
---|
| 11 | """ |
---|
| 12 | wftool = context.portal_workflow |
---|
| 13 | from urllib import urlencode |
---|
| 14 | from Products.CPSDocument.utils import getFormUidUrlArg |
---|
| 15 | import DateTime |
---|
| 16 | current = DateTime.DateTime() |
---|
| 17 | import logging |
---|
[1593] | 18 | logger = logging.getLogger('Skins.personal_edit') |
---|
[1457] | 19 | |
---|
| 20 | info = context.getPersonalInfo() |
---|
| 21 | |
---|
| 22 | if info is None: |
---|
[1593] | 23 | logger.info('Anonymous user tried to access %s' % REQUEST.get('URL0')) |
---|
[1457] | 24 | return REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url()) |
---|
| 25 | |
---|
| 26 | student = info['student'] |
---|
| 27 | per = info['per'] |
---|
| 28 | per_doc = info['per_doc'] |
---|
| 29 | state = info['review_state'] |
---|
| 30 | is_valid, ds = per_doc.validate(request=REQUEST, |
---|
| 31 | schema_id = 'student_personal', |
---|
| 32 | layout_id = 'student_personal_fe', |
---|
| 33 | proxy=per, |
---|
| 34 | use_session=True) |
---|
| 35 | |
---|
| 36 | psm = "" |
---|
| 37 | args = {} |
---|
| 38 | action = "/personal_edit_form" |
---|
| 39 | base_url = per.absolute_url() |
---|
| 40 | |
---|
| 41 | if is_valid: |
---|
| 42 | if cpsdocument_edit_button: |
---|
| 43 | name = "%(firstname)s %(middlename)s %(lastname)s" % ds |
---|
| 44 | name = name.strip() |
---|
| 45 | name = name.replace(' ',' ') |
---|
| 46 | email = ds.get('email') |
---|
| 47 | phone = ds.get('phone') |
---|
| 48 | student_id = context.getStudentId() |
---|
| 49 | context.students_catalog.modifyRecord(id = student_id, |
---|
| 50 | name = name, |
---|
| 51 | email = email, |
---|
| 52 | phone = phone, |
---|
| 53 | sex = ds.get('sex'), |
---|
| 54 | ) |
---|
[1593] | 55 | logger.info('%s edited personal data' % (info['id'])) |
---|
[1457] | 56 | #action = "" |
---|
| 57 | #base_url = student.absolute_url() |
---|
| 58 | #url = base_url + action |
---|
| 59 | psm = 'psm_content_changed' |
---|
| 60 | else: |
---|
| 61 | psm = 'psm_content_error' |
---|
| 62 | args = getFormUidUrlArg(REQUEST) |
---|
| 63 | |
---|
| 64 | args['portal_status_message'] = psm |
---|
| 65 | url = base_url + action + '?' + urlencode(args) |
---|
| 66 | REQUEST.RESPONSE.redirect(url) |
---|