[Mpuls-commits] r5010 - in base/trunk/mpulsweb: controllers model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri May 27 10:45:18 CEST 2011


Author: ludwig
Date: 2011-05-27 10:45:17 +0200 (Fri, 27 May 2011)
New Revision: 5010

Modified:
   base/trunk/mpulsweb/controllers/case_bundle.py
   base/trunk/mpulsweb/model/case.py
Log:
Issue1124: Changed the set standin handling to match the default behaviour of
the application.
All groups are now shown in the set standin dialog.
For every case the gid of the editor is filtered. So no editor can be standin.
If no case is modified, the default empty caselist is shown.


Modified: base/trunk/mpulsweb/controllers/case_bundle.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_bundle.py	2011-05-26 16:27:15 UTC (rev 5009)
+++ base/trunk/mpulsweb/controllers/case_bundle.py	2011-05-27 08:45:17 UTC (rev 5010)
@@ -137,8 +137,6 @@
                 user_list = UserListObject()
                 group_filter = [u.gid for u in user_list.getAdminList()]
                 group_filter.append(user.gid)
-                for case in case_bundle.getCases():
-                    group_filter.append(case.getEditor().gid)
                 c.group_list = group_list.getGroupList(group_filter)
                 c.case_list = case_bundle.getCases()
                 c.current_user = user
@@ -484,14 +482,19 @@
         try:
             form_result = validator.to_python(request.params)
             num = case_bundle.setStandin(form_result.get('standin'))
-            c.dialog_title = _(u"Stand-in appointed!")
-            c.dialog_text = (
+            if num > 0:
+                c.dialog_title = _(u"Stand-in appointed!")
+                c.dialog_text = (
                 ungettext(u"%s case was successfully assigned to a substitute.",
                           u"%s cases were successfully assigned to a"
                           u" substitute.",
                           num) % num + " " + OK_TO_CONTINUE)
+            else:
+                del session['casebundle']
+                return self._empty_caselist()
             c.url_ok = url_for(controller='/case_overview')
             del session['casebundle']
+            
             return render('/casebundle/dialogs/success_standin.mako')
         except formencode.Invalid, error:
             c.form_result = error.value

Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py	2011-05-26 16:27:15 UTC (rev 5009)
+++ base/trunk/mpulsweb/model/case.py	2011-05-27 08:45:17 UTC (rev 5010)
@@ -347,10 +347,14 @@
         num = 0
         for id in self.case_list:
             case = factory.loadById(id)
+            case_group_ids = group_ids[:]
+            if case.getEditor().gid in case_group_ids:
+                case_group_ids.remove(case.getEditor().gid)
             try:
-                standin = case.getStandin()
-                standin.setGroups(group_ids)
-                num += 1
+                if case_group_ids:
+                    standin = case.getStandin()
+                    standin.setGroups(case_group_ids)
+                    num += 1
             except Exception, e:
                 log.exception(e)
         return num



More information about the Mpuls-commits mailing list