source: WAeUP_SRP/trunk/skins/waeup_default/waeup_edit.py @ 15131

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

beautify logging message

File size: 2.4 KB
RevLine 
[859]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"""
[3356]5try:
6    from Products.zdb import set_trace
7except:
8    def set_trace():
9        pass
[859]10
11from urllib import urlencode
12from Products.CPSDocument.utils import getFormUidUrlArg
[2018]13if 'ajax_edit' in REQUEST.form:
14    return context.waeup_edit_ajax(REQUEST, cluster=cluster)
[859]15
[1571]16import logging
17logger = logging.getLogger('Skins.waeup_edit')
18
19mtool = context.portal_membership
20member = mtool.getAuthenticatedMember()
[3301]21doc = context.getContent()
[1571]22
[3301]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)
[3356]30old_values = dict([(k,v) for k,v in doc.getDataModel().items()])
[859]31
32is_valid, ds = doc.validate(request=REQUEST, proxy=context, cluster=cluster,
33                            use_session=True)
[1840]34student_id = context.getStudentId()
[859]35action = "/" + came_from
36if is_valid:
[3356]37    # comments = REQUEST.get('comments')
38    # context.cpsdocument_notify_modification(comments=comments)
[859]39    if cpsdocument_edit_and_view_button is not None:
40        action = ''
[3356]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]]
[3357]43    if student_id:
44        logger.info('%s edited %s object (fields %s) of %s' % (member,
45                                               
46                                                context.id,
47                                                ', '.join(changed),
48                                                student_id))
49    else:
50        logger.info('%s edited %s %s (fields %s)' % (member,
[3356]51                                                context.portal_type,
52                                                context.id,
[3357]53                                                ', '.join(changed),
54                                                ))   
55       
[859]56    psm = 'psm_content_changed'
57    args = {}
58else:
59    psm = 'psm_content_error'
60    args = getFormUidUrlArg(REQUEST)
61
62args['portal_status_message'] = psm
63url = context.absolute_url() + action + '?' + urlencode(args)
64REQUEST.RESPONSE.redirect(url)
65
Note: See TracBrowser for help on using the repository browser.