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 | """ |
---|
4 | """ |
---|
5 | |
---|
6 | from urllib import urlencode |
---|
7 | from Products.CPSDocument.utils import getFormUidUrlArg |
---|
8 | if 'ajax_edit' in REQUEST.form: |
---|
9 | return context.waeup_edit_ajax(REQUEST, cluster=cluster) |
---|
10 | |
---|
11 | import logging |
---|
12 | logger = logging.getLogger('Skins.waeup_edit') |
---|
13 | |
---|
14 | mtool = context.portal_membership |
---|
15 | member = mtool.getAuthenticatedMember() |
---|
16 | doc = context.getContent() |
---|
17 | |
---|
18 | #if context.portal_type == "StudentStudyCourse": |
---|
19 | # if len(context.objectIds()) > 0: |
---|
20 | # psm = 'Edit of StudentStudyCourse is only possible if there are no levels inside!' |
---|
21 | # args = getFormUidUrlArg(REQUEST) |
---|
22 | # args['portal_status_message'] = psm |
---|
23 | # url = context.absolute_url() + '?' + urlencode(args) |
---|
24 | # return REQUEST.RESPONSE.redirect(url) |
---|
25 | |
---|
26 | is_valid, ds = doc.validate(request=REQUEST, proxy=context, cluster=cluster, |
---|
27 | use_session=True) |
---|
28 | |
---|
29 | student_id = context.getStudentId() |
---|
30 | |
---|
31 | action = "/" + came_from |
---|
32 | if is_valid: |
---|
33 | comments = REQUEST.get('comments') |
---|
34 | context.cpsdocument_notify_modification(comments=comments) |
---|
35 | |
---|
36 | |
---|
37 | |
---|
38 | if cpsdocument_edit_and_view_button is not None: |
---|
39 | action = '' |
---|
40 | psm = 'psm_content_changed' |
---|
41 | args = {} |
---|
42 | else: |
---|
43 | psm = 'psm_content_error' |
---|
44 | args = getFormUidUrlArg(REQUEST) |
---|
45 | |
---|
46 | logger.info('%s edited %s %s of %s' % (member,context.portal_type,context.id,student_id)) |
---|
47 | args['portal_status_message'] = psm |
---|
48 | url = context.absolute_url() + action + '?' + urlencode(args) |
---|
49 | REQUEST.RESPONSE.redirect(url) |
---|
50 | |
---|