[Mpuls-commits] r2264 - wasko/branches/2.0/mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Mar 31 15:06:43 CEST 2010


Author: torsten
Date: 2010-03-31 15:06:43 +0200 (Wed, 31 Mar 2010)
New Revision: 2264

Modified:
   wasko/branches/2.0/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py (MpulsCase.get_infofield_fields): Added new
	method to get fields shown in infofield. Further added new option to
	set a label for each field in the infofield.


Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-03-31 13:05:14 UTC (rev 2263)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-03-31 13:06:43 UTC (rev 2264)
@@ -188,6 +188,12 @@
        overview -- If true (default false), the field will be listed in the
                default caseoverview
 
+       info -- If true (default false), the field will be listed in the
+               default infofield 
+
+       info_label --  Defines a label to be used in the infofield.
+               Default will be the name of the field.
+
        overview_label -- Defines a label to be used in the overviewpage.
                Default will be the name of the field.
 
@@ -228,7 +234,8 @@
                This setting only has an affect if alias is not None.
     """
 
-    def __init__(self, name, digest=False,
+    def __init__(self, name, digest=False, 
+                 info=False, info_label=None,
                  search_retrieve=False, search_match=False,
                  session=False, preload=False,
                  alias=None, alias_force_string=True,
@@ -237,6 +244,8 @@
 
         self.name = name
         self.digest = digest
+        self.info = info 
+        self.info_label = info_label or name
         self.search_retrieve = search_retrieve
         self.search_match = search_match
 
@@ -249,6 +258,7 @@
         self.overview_label = overview_label or name
         self.overview_style = overview_style
 
+
     @property
     def default(self):
         """Return the default value when accessed via the alias name"""
@@ -514,6 +524,11 @@
         return [field for field in cls.fields if field.digest]
 
     @classmethod
+    def get_infofield_fields(cls):
+        """Return a list describing all fields shown in the infofield."""
+        return [field for field in cls.fields if field.info]
+
+    @classmethod
     def get_search_retrieve_fields(cls):
         """Return a list with all names of fields to retrieve from the search"""
         return [field.name for field in cls.fields if field.search_retrieve]
@@ -611,6 +626,7 @@
     def getSessionCase(self):
         """Return a SessionCase object initialized from the current case"""
         fields = dict()
+        log.debug('a1')
         for field in self.get_session_fields():
             # FIXME: Ideally we would use
             # self.get_value(field.name) to get the value.  We use
@@ -619,7 +635,12 @@
             # (e.g. buildInfofield in
             # templates/casemanagement/main.mako) relies on.
             fields[field.alias] = getattr(self, field.alias)
-        signed = self.getPrivacyStatement().isSigned()
+        log.debug('a2')
+        if g.mpuls_config.is_enabled('case-module', 'privacy'):
+            signed = self.getPrivacyStatement().isSigned()
+        else:
+            signed = True
+        log.debug('a3')
         return SessionCase(self.id, state=self.state,
                            privacy_statement=signed,
                            **fields)
@@ -825,6 +846,9 @@
     def _session_fields(self):
         return g.case_factory.get_session_fields()
 
+    def get_value(self, name):
+        return getattr(self, name)
+
     def getState(self):
         return self.state
 



More information about the Mpuls-commits mailing list