source: WAeUP_SRP/base/skins/waeup_default/waeup_edit.py @ 3356

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

resolve #509

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