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

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

beautify logging message

File size: 2.4 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    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,
51                                                context.portal_type,
52                                                context.id,
53                                                ', '.join(changed),
54                                                ))   
55       
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.