Changeset 13986 for main/waeup.kofa/trunk/src
- Timestamp:
- 24 Jun 2016, 06:27:41 (9 years ago)
- 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 34 34 mandate_id = form.get('mandate_id', None) 35 35 if not mandate_id: 36 self.flash(_('Misuse'))36 (self.msg, self.redirect_path) = (_('Misuse'), '') 37 37 return 38 38 mandates = grok.getSite()['mandates'] 39 39 mandate = mandates.get(mandate_id, None) 40 40 if mandate is None: 41 self.flash(_('No mandate.'))41 (self.msg, self.redirect_path) = (_('No mandate.'), '') 42 42 return 43 msg = mandate.execute() 44 self.flash(msg) 43 (self.msg, self.redirect_path) = mandate.execute() 45 44 return 46 45 47 46 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)) 49 49 return -
main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py
r11681 r13986 67 67 def execute(self): 68 68 msg = _('Wrong mandate parameters.') 69 redirect_path = '' 69 70 if self.expires < datetime.utcnow(): 70 71 msg = _('Mandate expired.') … … 75 76 grok.getSite().logger.info( 76 77 'PasswordMandate used: %s ' % username) 78 redirect_path = 'login' 77 79 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 90 90 mandate = PasswordMandate() 91 91 self.app['mandates'].addMandate(mandate) 92 msg = mandate.execute() 92 (msg, redirect_path) = mandate.execute() 93 self.assertEqual(redirect_path, '') 93 94 self.assertEqual(msg, u'Wrong mandate parameters.') 94 95 # Add and execute an expired mandate. 95 96 mandate = PasswordMandate(days=0) 96 97 self.app['mandates'].addMandate(mandate) 97 msg= mandate.execute()98 (msg, redirect_path) = mandate.execute() 98 99 self.assertEqual(msg, u'Mandate expired.') 100 self.assertEqual(redirect_path, '') 99 101 # Add and execute a perfect mandate 100 102 mandate = PasswordMandate() … … 102 104 mandate.params['password'] = 'mypwd1' 103 105 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') 107 111 self.assertTrue(IUserAccount(student).checkPassword('mypwd1')) 108 112 # All mandates have been removed. … … 120 124 mandate.params['password'] = 'mypwd1' 121 125 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') 125 131 self.assertTrue(IUserAccount(officer).checkPassword('mypwd1')) 126 132 logfile = os.path.join( … … 136 142 mandate.params['password'] = 'mypwd1' 137 143 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') 141 149 self.assertTrue(IUserAccount(applicant).checkPassword('mypwd1')) 142 150 logfile = os.path.join( … … 197 205 # We redirect to login page not to the frontpage. 198 206 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.