Index: /main/waeup.kofa/trunk/src/waeup/kofa/mandates/browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/mandates/browser.py	(revision 8848)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/mandates/browser.py	(revision 8848)
@@ -0,0 +1,50 @@
+## $Id$
+##
+## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+"""Views for mandates.
+"""
+import grok
+from waeup.kofa.browser.layout import UtilityView
+from waeup.kofa.interfaces import IUniversity
+from waeup.kofa.interfaces import MessageFactory as _
+
+class MandateView(UtilityView, grok.View):
+    """View to execute mandate.
+    """
+    grok.context(IUniversity)
+    grok.name('mandate')
+    grok.require('waeup.Public')
+
+    def update(self, *args, **kw):
+        form = self.request.form
+        mandate_id = form.get('mandate_id', None)
+        if not mandate_id:
+            self.flash(_('Misuse'))
+            return
+        mandates = grok.getSite()['mandates']
+        mandate = mandates.get(mandate_id, None)
+        if mandate is None:
+            self.flash(_('No mandate.'))
+            return
+        msg = mandate.execute()
+        self.flash(msg)
+        self.redirect(self.url(self.context))
+        return
+
+    def render(self):
+        self.redirect(self.url(self.context))
+        return
Index: /main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py	(revision 8847)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/mandates/mandate.py	(revision 8848)
@@ -60,5 +60,5 @@
         if self.expires < datetime.utcnow():
             msg = _('Mandate expired.')
-        if self.category == 'student_password':
+        elif self.category == 'student_password':
             if self._setStudentPassword():
                 msg = _('Password has been successfully set.')
Index: /main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py	(revision 8847)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/mandates/tests.py	(revision 8848)
@@ -21,4 +21,5 @@
 import tempfile
 import shutil
+from zope.testbrowser.testing import Browser
 from datetime import datetime, timedelta
 from zope.interface.verify import verifyClass, verifyObject
@@ -75,4 +76,7 @@
         setSite(app)
 
+        self.browser = Browser()
+        self.browser.handleErrors = False
+
     def tearDown(self):
         super(MandatesContainerTestCase, self).tearDown()
@@ -95,6 +99,6 @@
         msg = mandate.execute()
         self.assertEqual(msg, u'Mandate expired.')
-        # Ad and execute a perfect mandate
-        mandate = Mandate(days=0)
+        # Add and execute a perfect mandate
+        mandate = Mandate()
         mandate.category = 'student_password'
         mandate.params['student_id'] = student.student_id
@@ -120,2 +124,19 @@
         self.assertEqual(len(self.app['mandates'].keys()), 1)
         self.assertEqual([i for i in self.app['mandates'].keys()], [u'23456'])
+
+    def test_browser(self):
+        student = createObject('waeup.Student')
+        self.app['students'].addStudent(student)
+        mandate = Mandate()
+        mandate.category = 'student_password'
+        mandate.params['student_id'] = student.student_id
+        mandate.params['password'] = 'mypwd1'
+        self.app['mandates'].addMandate(mandate)
+        self.browser.open('http://localhost/app/mandate?mandate_id=%s'
+            % mandate.mandate_id)
+        # Password has been set.
+        self.assertTrue('Password has been successfully set.'
+            in self.browser.contents)
+        self.assertTrue(IUserAccount(student).checkPassword('mypwd1'))
+        # All mandates have been removed.
+        self.assertEqual(len(self.app['mandates'].keys()), 0)
