Changeset 13986


Ignore:
Timestamp:
24 Jun 2016, 06:27:41 (9 years ago)
Author:
Henrik Bettermann
Message:

Provision for the new RefereeReportMandate? which redirects to another url.

Location:
main/waeup.kofa/trunk/src/waeup/kofa/mandates
Files:
3 edited

Legend:

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

    r11680 r13986  
    3434        mandate_id = form.get('mandate_id', None)
    3535        if not mandate_id:
    36             self.flash(_('Misuse'))
     36            (self.msg, self.redirect_path) = (_('Misuse'), '')
    3737            return
    3838        mandates = grok.getSite()['mandates']
    3939        mandate = mandates.get(mandate_id, None)
    4040        if mandate is None:
    41             self.flash(_('No mandate.'))
     41            (self.msg, self.redirect_path) = (_('No mandate.'), '')
    4242            return
    43         msg = mandate.execute()
    44         self.flash(msg)
     43        (self.msg, self.redirect_path) = mandate.execute()
    4544        return
    4645
    4746    def render(self):
    48         self.redirect(self.url(self.context, 'login'))
     47        self.flash(self.msg)
     48        self.redirect(self.url(self.context, self.redirect_path))
    4949        return
  • main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py

    r11681 r13986  
    6767    def execute(self):
    6868        msg = _('Wrong mandate parameters.')
     69        redirect_path = ''
    6970        if self.expires < datetime.utcnow():
    7071            msg = _('Mandate expired.')
     
    7576            grok.getSite().logger.info(
    7677                'PasswordMandate used: %s ' % username)
     78            redirect_path = 'login'
    7779        del self.__parent__[self.mandate_id]
    78         return msg
     80        return msg, redirect_path
  • main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py

    r13962 r13986  
    9090        mandate = PasswordMandate()
    9191        self.app['mandates'].addMandate(mandate)
    92         msg = mandate.execute()
     92        (msg, redirect_path) = mandate.execute()
     93        self.assertEqual(redirect_path, '')
    9394        self.assertEqual(msg, u'Wrong mandate parameters.')
    9495        # Add and execute an expired mandate.
    9596        mandate = PasswordMandate(days=0)
    9697        self.app['mandates'].addMandate(mandate)
    97         msg = mandate.execute()
     98        (msg, redirect_path) = mandate.execute()
    9899        self.assertEqual(msg, u'Mandate expired.')
     100        self.assertEqual(redirect_path, '')
    99101        # Add and execute a perfect mandate
    100102        mandate = PasswordMandate()
     
    102104        mandate.params['password'] = 'mypwd1'
    103105        self.app['mandates'].addMandate(mandate)
    104         msg = mandate.execute()
    105         # Password has been set.
    106         self.assertEqual(msg, 'Password has been successfully set. Login with your new password.')
     106        (msg, redirect_path) = mandate.execute()
     107        # Password has been set.
     108        self.assertEqual(msg,
     109            'Password has been successfully set. Login with your new password.')
     110        self.assertEqual(redirect_path, 'login')
    107111        self.assertTrue(IUserAccount(student).checkPassword('mypwd1'))
    108112        # All mandates have been removed.
     
    120124        mandate.params['password'] = 'mypwd1'
    121125        self.app['mandates'].addMandate(mandate)
    122         msg = mandate.execute()
    123         # Password has been set.
    124         self.assertEqual(msg, 'Password has been successfully set. Login with your new password.')
     126        (msg, redirect_path) = mandate.execute()
     127        # Password has been set.
     128        self.assertEqual(msg,
     129            'Password has been successfully set. Login with your new password.')
     130        self.assertEqual(redirect_path, 'login')
    125131        self.assertTrue(IUserAccount(officer).checkPassword('mypwd1'))
    126132        logfile = os.path.join(
     
    136142        mandate.params['password'] = 'mypwd1'
    137143        self.app['mandates'].addMandate(mandate)
    138         msg = mandate.execute()
    139         # Password has been set.
    140         self.assertEqual(msg, 'Password has been successfully set. Login with your new password.')
     144        (msg, redirect_path) = mandate.execute()
     145        # Password has been set.
     146        self.assertEqual(msg,
     147            'Password has been successfully set. Login with your new password.')
     148        self.assertEqual(redirect_path, 'login')
    141149        self.assertTrue(IUserAccount(applicant).checkPassword('mypwd1'))
    142150        logfile = os.path.join(
     
    197205        # We redirect to login page not to the frontpage.
    198206        self.assertEqual(self.browser.url, 'http://localhost/app/login')
     207        # Mandate has been deleted
     208        self.browser.open('http://localhost/app/mandate?mandate_id=%s'
     209            % mandate.mandate_id)
     210        self.assertTrue('No mandate' in self.browser.contents)
     211        self.assertEqual(self.browser.url, 'http://localhost/app/')
     212        # Mandate id is needed
     213        self.browser.open('http://localhost/app/mandate')
     214        self.assertTrue('Misuse' in self.browser.contents)
     215        self.assertEqual(self.browser.url, 'http://localhost/app/')
     216        return
Note: See TracChangeset for help on using the changeset viewer.