Changeset 9122 for main/waeup.kofa


Ignore:
Timestamp:
29 Aug 2012, 11:53:22 (12 years ago)
Author:
Henrik Bettermann
Message:

Let's edit application histories too.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/utils
Files:
2 edited

Legend:

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

    r9012 r9122  
    3232        history = IObjectHistory(student)
    3333        history.modifyMessages(old, new)
     34    return
     35
     36def replaceApplicantMessages(old, new):
     37    applicants = grok.getSite()['applicants']
     38    for container in applicants.values():
     39        for applicant in container.values():
     40            history = IObjectHistory(applicant)
     41            history.modifyMessages(old, new)
    3442    return
    3543
     
    8593        self.redirect(self.url(self.context, '@@index'))
    8694        return
     95
     96class ModifyAllApplicantHistory(UtilityView, grok.View):
     97    """ View to modify all student histories.
     98
     99    """
     100    grok.context(IUniversity)
     101    grok.name('modify_applicant_history')
     102    grok.require('waeup.managePortal')
     103
     104    def update(self,old=None, new=None):
     105        if None in (old, new):
     106            self.flash('Syntax: /modify_applicant_history?old=[old string]&new=[new string]')
     107            return
     108        replaceApplicantMessages(old, new)
     109        self.context.logger.info(
     110            "'%s' replaced by '%s' in all applicant histories." % (old, new))
     111        self.flash('Finished')
     112        return
     113
     114    def render(self):
     115        self.redirect(self.url(self.context, '@@index'))
     116        return
  • main/waeup.kofa/trunk/src/waeup/kofa/utils/tests/test_browser.py

    r9022 r9122  
    3535from waeup.kofa.utils.browser import replaceStudentMessages
    3636from waeup.kofa.students.tests.test_browser import StudentsFullSetup
     37from waeup.kofa.applicants.tests.test_browser import ApplicantsFullSetup
    3738
    38 class UtilsUITests(StudentsFullSetup):
     39class StudentUtilsUITests(StudentsFullSetup):
    3940
    4041    layer = FunctionalLayer
     
    7778        results = cat.searchResults(student_id=(None, None))
    7879        self.assertEqual(len(results),1)
     80
     81class ApplicantUtilsUITests(ApplicantsFullSetup):
     82
     83    layer = FunctionalLayer
     84
     85    def test_modify_all_applicant_history(self):
     86        self.assertTrue('Application initialized by system' in
     87            self.applicant.history.messages[0])
     88        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
     89        self.browser.open('http://localhost/app/modify_applicant_history')
     90        self.assertTrue(
     91            'Syntax: /modify_applicant_history?old=[old string]&new=[new string]'
     92            in self.browser.contents)
     93        self.browser.open(
     94            'http://localhost/app/modify_applicant_history?old=by system&new=by me')
     95        self.assertTrue('Finished' in self.browser.contents)
     96        self.assertTrue('Application initialized by me' in
     97            self.applicant.history.messages[0])
Note: See TracChangeset for help on using the changeset viewer.