Ignore:
Timestamp:
4 Nov 2012, 21:51:57 (12 years ago)
Author:
Henrik Bettermann
Message:

Log changes when saving ApplicantsContainerManageFormPage?.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/applicants
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r9529 r9531  
    397397    @action(_('Save'), style='primary')
    398398    def save(self, **data):
    399         self.applyData(self.context, **data)
     399        changed_fields = self.applyData(self.context, **data)
     400        if changed_fields:
     401            changed_fields = reduce(lambda x,y: x+y, changed_fields.values())
     402        else:
     403            changed_fields = []
    400404        self.context.description_dict = self._description()
    401405        # Always refresh title. So we can change titles
     
    406410            title, self.context.year, self.context.year + 1)
    407411        self.flash(_('Form has been saved.'))
     412        fields_string = ' + '.join(changed_fields)
     413        self.context.writeLogMessage(self, 'saved: % s' % fields_string)
    408414        return
    409415
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/container.py

    r8993 r9531  
    113113        return False
    114114
     115    def writeLogMessage(self, view, message):
     116        ob_class = view.__implemented__.__name__.replace('waeup.kofa.','')
     117        self.__parent__.logger.info(
     118            '%s - %s - %s' % (ob_class, self.code, message))
     119        return
    115120
    116121ApplicantsContainer = attrs_to_fields(ApplicantsContainer)
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/interfaces.py

    r9217 r9531  
    290290        """
    291291
     292    def writeLogMessage(view, comment):
     293        """Adds an INFO message to the log file
     294        """
     295
    292296class IApplicantsContainerAdd(IApplicantsContainer):
    293297    """An applicants container contains university applicants.
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r9398 r9531  
    1919Test the applicant-related UI components.
    2020"""
     21import os
    2122import pytz
    2223import shutil
     
    370371        self.assertEqual(self.browser.headers['Status'], '200 Ok')
    371372        self.assertEqual(self.browser.url, self.manage_container_path)
     373        self.browser.getControl(name="form.application_fee").value = '200'
    372374        self.browser.getControl("Save").click()
    373375        self.assertTrue('Form has been saved' in self.browser.contents)
     376        logfile = os.path.join(
     377            self.app['datacenter'].storage, 'logs', 'applicants.log')
     378        logcontent = open(logfile).read()
     379        self.assertTrue(
     380            'zope.mgr - applicants.browser.ApplicantsContainerManageFormPage - '
     381            'app2010 - saved: application_fee\n' in logcontent)
    374382        self.browser.getControl("Remove selected", index=0).click()
    375383        self.assertTrue('No applicant selected' in self.browser.contents)
Note: See TracChangeset for help on using the changeset viewer.