[Mpuls-commits] r5288 - in jmd/trunk: . jmdstrukturweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Aug 31 11:57:48 CEST 2011


Author: roland
Date: 2011-08-31 11:57:47 +0200 (Wed, 31 Aug 2011)
New Revision: 5288

Modified:
   jmd/trunk/jmdstruktur.json
   jmd/trunk/jmdstrukturweb/controllers/jmdstruktur.py
   jmd/trunk/tagging_struktur.xml
Log:
Issue2231: Added tagging for structure statistics.


Modified: jmd/trunk/jmdstruktur.json
===================================================================
--- jmd/trunk/jmdstruktur.json	2011-08-31 07:07:38 UTC (rev 5287)
+++ jmd/trunk/jmdstruktur.json	2011-08-31 09:57:47 UTC (rev 5288)
@@ -23,6 +23,9 @@
 		"tags": "1",
 		"checktags": "1"
 	},
+	"overview_tags": {
+        "tag_ids": ["100"]
+	},
 	"phases": {
 		"changemode": "2",
 		"phases": ["-1","0"],

Modified: jmd/trunk/jmdstrukturweb/controllers/jmdstruktur.py
===================================================================
--- jmd/trunk/jmdstrukturweb/controllers/jmdstruktur.py	2011-08-31 07:07:38 UTC (rev 5287)
+++ jmd/trunk/jmdstrukturweb/controllers/jmdstruktur.py	2011-08-31 09:57:47 UTC (rev 5288)
@@ -2,6 +2,8 @@
 import logging
 from mpulsweb.controllers.mpuls import MpulsController
 from jmdstrukturweb.model.appointment import StatisticReminderOverview
+from mpulsweb.model.appointment import TagsReminderOverview
+import mpulsweb.lib.helpers as h
 
 log = logging.getLogger(__name__)
 
@@ -12,5 +14,11 @@
         the user to create a new statistic.
         """
         remindlist = StatisticReminderOverview()
+        
+        if h.hasRole(['cm']):
+            remindlist.join(TagsReminderOverview())
+        
+        remindlist.sort()
+        
         return remindlist
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

Modified: jmd/trunk/tagging_struktur.xml
===================================================================
--- jmd/trunk/tagging_struktur.xml	2011-08-31 07:07:38 UTC (rev 5287)
+++ jmd/trunk/tagging_struktur.xml	2011-08-31 09:57:47 UTC (rev 5288)
@@ -4,42 +4,66 @@
     <name>Alle</name>
     <desc>Jede Fallakte hat einen Tag</desc>
     <addtag>
-      <sql>SELECT id from ( %(table)s ) m</sql>
+      <sql>SELECT id FROM ( %(table)s ) m</sql>
     </addtag>
     <deltag>
-      <sql>SELECT id from ( %(table)s ) m</sql>
+      <sql>SELECT id FROM ( %(table)s ) m</sql>
     </deltag>
   </check>
 
   <!-- Es darf nur eine Fallakte pro Jahr angelegt werden -->
-  <check tagid="1">
-    <name>Alle</name>
-    <desc>Es darf nur eine Fallakte pro Jahr angelegt werden</desc>
+  <check tagid="100">
+    <name>Doppelte Strukturdaten</name>
+    <desc>Es darf nur eine Strukturakte pro Jahr angelegt werden</desc>
     <addtag>
-      <sql>SELECT id from ( %(table)s ) m
-        WHERE (datum_begin_zeitraum IS NOT NULL)
+      <sql>SELECT id FROM ( %(table)s ) m
+      WHERE date_trunc('year', datum_begin_zeitraum) IN (
+        SELECT date_trunc('year', datum_begin_zeitraum)
+            FROM master_tbl_view JOIN ka_status_tbl_view
+            ON master_tbl_view.id = ka_status_tbl_view.master_id
+            WHERE ka_status_tbl_view.status = 1 
+            GROUP BY date_trunc('year', datum_begin_zeitraum)
+            HAVING COUNT(1) > 1
+            )
         AND (datum_begin_zeitraum != '0001-01-01'::date)
         AND (datum_ende_zeitraum IS NOT NULL)
         AND (datum_ende_zeitraum != '0001-01-01'::date)
-        AND (SELECT COUNT(1) = 0
-                FROM master_tbl_view JOIN nm_tags_cases_view
-                    ON nm_tags_cases_view.case_id = master_tbl_view.id
-                WHERE master_tbl_view.id IN (%(master_id)s)
-                    AND nm_tags_cases_view.tag_id = 1
-            )
-        AND (SELECT COUNT(1) = 1
-                FROM master_tbl_view JOIN ka_status_tbl_view
-                ON master_tbl_view.id = ka_status_tbl_view.master_id
-                WHERE date_trunc('year', datum_begin_zeitraum::date) = (SELECT date_trunc('year', datum_begin_zeitraum)
-                                                                        FROM master_tbl_view
-                                                                        WHERE master_tbl_view.id IN (%(master_id)s))
-                    AND ka_status_tbl_view.status = 1
-            )
      </sql>
     </addtag>
     <deltag>
-      <sql>SELECT id from ( %(table)s ) m</sql>
+      <sql>SELECT id FROM ( %(table)s ) m</sql>
     </deltag>
   </check>
+  
+  <!-- Start und Enddatum angegeben -->
+  <check tagid="101">
+    <name>Start- und Enddaten gesetzt</name>
+    <desc>Die Angaben zum Start und Ende des Zeitraums müssen angegeben werden.</desc>
+    <addtag>
+      <sql>SELECT id FROM ( %(table)s ) m
+      WHERE (datum_begin_zeitraum = '0001-01-01'::date)
+        OR (datum_begin_zeitraum IS NULL)
+        OR (datum_ende_zeitraum = '0001-01-01'::date)
+        OR (datum_ende_zeitraum IS NULL)
+     </sql>
+    </addtag>
+    <deltag>
+      <sql>SELECT id FROM ( %(table)s ) m</sql>
+    </deltag>
+  </check>
+  
+  
+  
+  <!-- "Gütesiegel" für Auswertungen -->
+  <check tagid="1">
+    <name>Auswertbar</name>
+    <desc>Die JMD-Statistik ist konsistent und weist die benötigten Validitäten auf, die für eine grundsätzliche Auswertung erfüllt sein müssen. Die Fallakte steht in Auswertungen zur Verfügung</desc>
+    <addtag>
+      <sql>SELECT id FROM ( %(table)s ) m WHERE NOT ARRAY(SELECT tag_id FROM nm_tags_cases_view WHERE case_id = m.id)  &amp;&amp; ARRAY[100, 101]</sql>
+    </addtag>
+    <deltag>
+      <sql>SELECT id FROM ( %(table)s ) m</sql>
+    </deltag>
+  </check>
 
 </checks>



More information about the Mpuls-commits mailing list