Changeset 6762


Ignore:
Timestamp:
14 Sep 2011, 07:11:17 (13 years ago)
Author:
Henrik Bettermann
Message:

Add save msave function which is called by save methods in manager pages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.sirp/trunk/src/waeup/sirp/students/browser.py

    r6761 r6762  
    3939from waeup.sirp.students.workflow import CLEARANCE
    4040
     41# Save function used for save methods in manager pages
     42def msave(view, **data):
     43    form = view.request.form
     44    ob_class = view.__implemented__.__name__.replace('waeup.sirp.','')
     45    changed_fields = view.applyData(view.context, **data)
     46    changed_fields = changed_fields.values()
     47    fields_string = '+'.join(' + '.join(str(i) for i in b) for b in changed_fields)
     48    view.context._p_changed = True
     49    view.flash('Form has been saved.')
     50    if fields_string:
     51        try:
     52            view.context.loggerInfo(ob_class, 'saved: % s' % fields_string)
     53        except AttributeError:
     54            view.context.__parent__.loggerInfo(ob_class, 'saved: % s' % fields_string)
     55    return
     56
    4157class StudentsTab(PrimaryNavTab):
    4258    """Students tab in primary navigation.
     
    372388    @grok.action('Save')
    373389    def save(self, **data):
    374         changed_fields = self.applyData(self.context, **data)
    375         changed_fields = changed_fields.values()
    376         fields_string = '+'.join(' + '.join(str(i) for i in b) for b in changed_fields)
    377         self.context._p_changed = True
    378         form = self.request.form
    379         self.flash('Form has been saved.')
    380         ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
    381         if fields_string:
    382             self.context.loggerInfo(ob_class, 'saved: % s' % fields_string)
     390        msave(self, **data)
    383391        return
    384392
     
    416424    pnav = 4
    417425
     426    @grok.action('Save')
     427    def save(self, **data):
     428        msave(self, **data)
     429        return
     430
    418431class StudyCourseDisplayFormPage(WAeUPDisplayFormPage):
    419432    """ Page to display the student study course data
     
    452465    @grok.action('Save')
    453466    def save(self, **data):
    454         form = self.request.form
    455         ob_class = self.__implemented__.__name__.replace('waeup.sirp.','')
    456         changed_fields = self.applyData(self.context, **data)
    457         changed_fields = changed_fields.values()
    458         fields_string = '+'.join(' + '.join(str(i) for i in b) for b in changed_fields)
    459         self.context._p_changed = True
    460         self.flash('Form has been saved.')
    461         if fields_string:
    462             self.context.__parent__.loggerInfo(ob_class, 'saved: % s' % fields_string)
     467        msave(self, **data)
    463468        return
    464469
Note: See TracChangeset for help on using the changeset viewer.