[Mpuls-commits] r3001 - base/trunk/mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Jun 11 15:55:23 CEST 2010


Author: torsten
Date: 2010-06-11 15:55:23 +0200 (Fri, 11 Jun 2010)
New Revision: 3001

Modified:
   base/trunk/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCase.getValidity): Implemented setting the validity based on validity configuration in config file.


Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py	2010-06-11 13:47:58 UTC (rev 3000)
+++ base/trunk/mpulsweb/model/case.py	2010-06-11 13:55:23 UTC (rev 3001)
@@ -812,7 +812,18 @@
 
     def getValidity(self):
         '''Will return the id of the max validity based on set tags'''
-        return '0'
+        tags = set(self.getTags())
+        # Try to find the highest validity
+        validity = '0' # Default validity (Not valid) 
+        for v in g.mpuls_config.get('validities', 'enabled'):
+            req_tags = set(v.get('tags', []))
+            if tags.issuperset(req_tags): 
+                # case has all requried tags for this validity
+                # -> level up to next validity
+                validity = v.get('id')
+            else:
+                break
+        return validity 
 
     def getDocuments(self):
         """Returns a list of documents which are attached to this case"""



More information about the Mpuls-commits mailing list