[Mpuls-commits] r617 - in wasko/branches/1.0: . waskaweb/controllers waskaweb/model waskaweb/templates/casemanagement waskaweb/templates/casemanagement/dialogs

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Oct 5 10:23:54 CEST 2009


Author: torsten
Date: 2009-10-05 10:23:52 +0200 (Mon, 05 Oct 2009)
New Revision: 617

Added:
   wasko/branches/1.0/waskaweb/templates/casemanagement/dialogs/failed_checkvalidity.mako
   wasko/branches/1.0/waskaweb/templates/casemanagement/dialogs/success_checkvalidity.mako
Modified:
   wasko/branches/1.0/ChangeLog.txt
   wasko/branches/1.0/waskaweb/controllers/case_overview.py
   wasko/branches/1.0/waskaweb/model/case.py
   wasko/branches/1.0/waskaweb/templates/casemanagement/overview.mako
Log:
Added new function to check for validity in bundled actions.


Modified: wasko/branches/1.0/ChangeLog.txt
===================================================================
--- wasko/branches/1.0/ChangeLog.txt	2009-10-05 07:33:27 UTC (rev 616)
+++ wasko/branches/1.0/ChangeLog.txt	2009-10-05 08:23:52 UTC (rev 617)
@@ -7,6 +7,16 @@
 	  logbook was broken as the whole evaluation thing has changed. Added
 	  new template for logbook evaluations.
 
+	Added new bundled action to check cases for validity
+
+	* waskaweb/model/case.py,
+	  waskaweb/controllers/case_overview.py,
+	  waskaweb/templates/casemanagement/overview.mako,
+	  waskaweb/templates/casemanagement/dialogs/success_checkvalidity.mako,
+	  waskaweb/templates/casemanagement/dialogs/failed_checkvalidity.mako:
+	  Added function (bundle and single case) to check for validity. The
+	  function is currently commented out in bundles actions.
+
 2009-10-02	Torsten Irlaender	<torsten.irlaender at intevation.de> 
 
 	Issue438

Modified: wasko/branches/1.0/waskaweb/controllers/case_overview.py
===================================================================
--- wasko/branches/1.0/waskaweb/controllers/case_overview.py	2009-10-05 07:33:27 UTC (rev 616)
+++ wasko/branches/1.0/waskaweb/controllers/case_overview.py	2009-10-05 08:23:52 UTC (rev 617)
@@ -108,6 +108,11 @@
 RESTORE_NOTIFICATION_ERROR = u"""Bei dem Wiederherstellen der Fallakten ist ein Fehler aufgetreten. Bitte klicken Sie auf "OK", um fortzufahren."""
 SELECT_PARTS_FOR_EXPORT = u"Welche Bereiche der Fallakte(n) sollen exportiert werden?"
 
+CHECK_SUCCESS=u"""Fallakten überprüft!"""
+CHECK_SUCCESS_EXPLAINATION=u"""Die Fallakten wurde erfolgreich auf ihre Validität überprüft."""
+CHECK_ERROR=u"""Es ist ein Fehler aufgetreten"""
+CHECK_ERROR_EXPLAINATION=u"""Bei dem Überprüfen der Validität ist einer Fehler aufgetreten. Klicken Sie auf 'OK', um fortzufahren."""
+
 FORM_DEFAULTS_ADMIN = {'show_own': '1', \
                       'search_str': '', \
                       'show_open': '0', \
@@ -460,6 +465,11 @@
                 session['hide_search_option_on_eval'] = True
                 session.save()
                 redirect_to(controller='evaluate', action="evaluate", id=1);
+            elif action == 'check_validity':
+                if case_bundle.isEmpty(): return self._emptyListError()
+                session['casebundle'] = case_bundle
+                session.save()
+                return self.checkValidity(1)
             else:
                 raise HTTPNotFound()
 
@@ -670,6 +680,21 @@
         return render('/casemanagement/dialogs/notificate_bundle_restore.mako')
 
     @checkRole(('cm_ka', 'admin_ka'))
+    def checkValidity(self, confirmed):
+        confirmed           = self._checkBool(confirmed)
+        case_bundle         = session.get('casebundle')
+        try:
+            case_bundle.checkValidity()
+            c.success_for  = CHECK_SUCCESS
+            c.success_text = CHECK_SUCCESS_EXPLAINATION
+            return render('/casemanagement/dialogs/success_checkvalidity.mako')
+        except StandardError, err:
+            c.failed_for  = CHECK_ERROR
+            c.failed_test = CHECK_ERROR_EXPLAINATION
+            c.url_ok      = "/agency_overview/"
+            return render('/casemanagement/dialogs/failed_checkvalidity.mako')
+
+    @checkRole(('cm_ka', 'admin_ka'))
     def exportCSV(self, confirmed):
         confirmed           = self._checkBool(confirmed)
         case_bundle         = session.get('casebundle')

Modified: wasko/branches/1.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/1.0/waskaweb/model/case.py	2009-10-05 07:33:27 UTC (rev 616)
+++ wasko/branches/1.0/waskaweb/model/case.py	2009-10-05 08:23:52 UTC (rev 617)
@@ -196,6 +196,18 @@
     def __init__(self, case_ids=None):
         CaseList.__init__(self, case_ids)
 
+    def checkValidity(self):
+        factory = CaseFactory()
+        num = 0
+        for id in self.case_list:
+            case = factory.loadById(id)
+            try:
+                if case.checkValidity():
+                    num += 1
+            except:
+                print >> sys.stderr, "Could not set editor for case in bundle"
+        return num
+
     def setEditor(self, user_id):
         factory = CaseFactory()
         num = 0
@@ -959,6 +971,22 @@
             db.recycleConnection(con, cur)
         return self.editor
 
+    def checkValidity(self):
+        '''Call remote function which will check how valid the case is'''
+        con, curr = None, None
+        try:
+            con = db.getConnection()
+            cur = con.cursor()
+            try:
+                cur.execute('SELECT check_case(%s)' % self.id)
+            except:
+                con.rollback()
+                return False 
+            con.commit()
+        finally:
+            db.recycleConnection(con, cur)
+        return True
+
     def getPage(self, datapage=None):
         '''Returns a datapage with the given name of the case'''
         if not self.page is None: 

Added: wasko/branches/1.0/waskaweb/templates/casemanagement/dialogs/failed_checkvalidity.mako
===================================================================
--- wasko/branches/1.0/waskaweb/templates/casemanagement/dialogs/failed_checkvalidity.mako	2009-10-05 07:33:27 UTC (rev 616)
+++ wasko/branches/1.0/waskaweb/templates/casemanagement/dialogs/failed_checkvalidity.mako	2009-10-05 08:23:52 UTC (rev 617)
@@ -0,0 +1,6 @@
+## -*- coding: utf-8 -*- 
+<%inherit file="/main.mako" />
+<%def name="buildNavipath()">
+	${parent.buildNavipath()}
+</%def>
+<%include file="../../dialogs/success.mako" />

Added: wasko/branches/1.0/waskaweb/templates/casemanagement/dialogs/success_checkvalidity.mako
===================================================================
--- wasko/branches/1.0/waskaweb/templates/casemanagement/dialogs/success_checkvalidity.mako	2009-10-05 07:33:27 UTC (rev 616)
+++ wasko/branches/1.0/waskaweb/templates/casemanagement/dialogs/success_checkvalidity.mako	2009-10-05 08:23:52 UTC (rev 617)
@@ -0,0 +1,6 @@
+## -*- coding: utf-8 -*- 
+<%inherit file="/main.mako" />
+<%def name="buildNavipath()">
+	${parent.buildNavipath()}
+</%def>
+<%include file="../../dialogs/success.mako" />

Modified: wasko/branches/1.0/waskaweb/templates/casemanagement/overview.mako
===================================================================
--- wasko/branches/1.0/waskaweb/templates/casemanagement/overview.mako	2009-10-05 07:33:27 UTC (rev 616)
+++ wasko/branches/1.0/waskaweb/templates/casemanagement/overview.mako	2009-10-05 08:23:52 UTC (rev 617)
@@ -40,6 +40,7 @@
       <option value="exportXLS">Als Excel-Tabellen exportieren</option>
       <option value="exportXML">Als XML-Datei exportieren</option>
       <option value="exportCSV">Als CSV-Datei exportieren</option>
+      ##<option value="check_validity">Validität überprüfen</option>
       ##% if not c.hide_evaluation:
       ##  <option value="evaluate">Auswerten</option>
       ##% endif



More information about the Mpuls-commits mailing list