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

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Mon Apr 23 13:38:57 CEST 2012


Author: ludwig
Date: 2012-04-23 13:38:57 +0200 (Mon, 23 Apr 2012)
New Revision: 5942

Modified:
   base/trunk/mpulsweb/controllers/case_overview.py
   base/trunk/mpulsweb/lib/search.py
   base/trunk/mpulsweb/model/case.py
Log:
Issue 3040 Add code to search for the max pages with the same options
like the search.


Modified: base/trunk/mpulsweb/controllers/case_overview.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_overview.py	2012-04-20 14:05:06 UTC (rev 5941)
+++ base/trunk/mpulsweb/controllers/case_overview.py	2012-04-23 11:38:57 UTC (rev 5942)
@@ -121,6 +121,8 @@
             options = self.parseSearchOptions(search_options,
                                         extended=session.get("EXTENDED_SEARCH"))
             cases.search(options)
+            if hasattr(self, "get_pages_count"):
+                cases.set_count(self.get_pages_count(options))
         return cases
 
     def _renderOverview(self, cases, form_results, form_defaults, form_errors):

Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py	2012-04-20 14:05:06 UTC (rev 5941)
+++ base/trunk/mpulsweb/lib/search.py	2012-04-23 11:38:57 UTC (rev 5942)
@@ -542,7 +542,30 @@
         SQL = self.SEARCH_QUERY % sql_fields
         return SQL
 
+class CaseCountSearch(Search):
 
+    SEARCH_QUERY = """
+    SELECT COUNT(*)
+    FROM master_tbl_view m
+    JOIN ka_status_tbl_view st ON m.id = st.master_id
+    JOIN ka_benutzer_tbl b ON m.bearbeiter_id = b.id
+    WHERE %(where)s
+    """
+
+    VALID_OPTIONS = Search.VALID_OPTIONS
+    MULTI_OPTIONS = Search.MULTI_OPTIONS + ('state', 'phase')
+
+
+    def __init__(self):
+        Search.__init__(self)
+
+    def _build_sql(self, options):
+        sql_fields = {}
+        sql_fields['where'] = self.get_where(options)
+
+        SQL = self.SEARCH_QUERY % sql_fields
+        return SQL
+
 class EvaluationSearch(Search):
 
     SEARCH_QUERY = """

Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py	2012-04-20 14:05:06 UTC (rev 5941)
+++ base/trunk/mpulsweb/model/case.py	2012-04-23 11:38:57 UTC (rev 5942)
@@ -1358,6 +1358,7 @@
 
     def __init__(self):
         self.ds_list = []
+        self.pages = 0
 
     def search(self, search_str=None):
         self.ds_list = []
@@ -1374,7 +1375,12 @@
     def getDatasets(self):
         return self.ds_list
 
+    def get_count(self):
+        return self.pages
 
+    def set_count(self, pages_count):
+        self.pages = pages_count
+
 class MpulsCaseState(object):
 
     """This class store the state and the last accesstime of the case.



More information about the Mpuls-commits mailing list