Ignore:
Timestamp:
17 Jun 2012, 06:42:20 (13 years ago)
Author:
Henrik Bettermann
Message:

Let's use the msave helper function also in university and other packages. msave applies applyData to the view and writes a view-specific log message. The context object of the view must have a writeLogMessage method.

In the students package writeLogMessage is now provided by all classes which implement IStudentNavigation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/helpers.py

    r8633 r8735  
    3838from zope.security.management import getInteraction
    3939from zope.pluggableauth.interfaces import IAuthenticatorPlugin
     40from waeup.kofa.interfaces import MessageFactory as _
    4041
    4142BUFSIZE = 8 * 1024
     
    682683        writer.writerow(row)
    683684    return tmp_path
     685
     686# Save function used for save methods in pages
     687def msave(view, **data):
     688    changed_fields = view.applyData(view.context, **data)
     689    # Turn list of lists into single list
     690    if changed_fields:
     691        changed_fields = reduce(lambda x,y: x+y, changed_fields.values())
     692    # Inform catalog if certificate has changed
     693    # (applyData does this only for the context)
     694    if 'certificate' in changed_fields:
     695        notify(grok.ObjectModifiedEvent(view.context.getStudent()))
     696    fields_string = ' + '.join(changed_fields)
     697    view.flash(_('Form has been saved.'))
     698    if fields_string:
     699        view.context.writeLogMessage(view, 'saved: %s' % fields_string)
     700    return
Note: See TracChangeset for help on using the changeset viewer.