[Mpuls-commits] r786 - in wasko/branches/2.0: . waskaweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Jan 20 15:14:01 CET 2010


Author: bh
Date: 2010-01-20 15:13:59 +0100 (Wed, 20 Jan 2010)
New Revision: 786

Modified:
   wasko/branches/2.0/ChangeLog.txt
   wasko/branches/2.0/waskaweb/controllers/waska.py
Log:
* waskaweb/controllers/waska.py (WaskaController.start)
(get_remindlist, get_newslist, get_case_appointments)
(get_global_appointments): Split most of the code of
WaskaController.start into the new get_* functions.  The
inconsistency reporting has been removed for now.


Modified: wasko/branches/2.0/ChangeLog.txt
===================================================================
--- wasko/branches/2.0/ChangeLog.txt	2010-01-20 13:58:08 UTC (rev 785)
+++ wasko/branches/2.0/ChangeLog.txt	2010-01-20 14:13:59 UTC (rev 786)
@@ -1,5 +1,13 @@
 2010-01-20  Bernhard Herzog  <bh at intevation.de>
 
+	* waskaweb/controllers/waska.py (WaskaController.start)
+	(get_remindlist, get_newslist, get_case_appointments)
+	(get_global_appointments): Split most of the code of
+	WaskaController.start into the new get_* functions.  The
+	inconsistency reporting has been removed for now.
+
+2010-01-20  Bernhard Herzog  <bh at intevation.de>
+
 	* waskaweb/lib/config.py (MpulsConfig.build_defaults): Add some
 	settings to enable/disable modules and case modules.
 

Modified: wasko/branches/2.0/waskaweb/controllers/waska.py
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/waska.py	2010-01-20 13:58:08 UTC (rev 785)
+++ wasko/branches/2.0/waskaweb/controllers/waska.py	2010-01-20 14:13:59 UTC (rev 786)
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 #
-# Copyright 2007, 2008 Intevation GmbH, Germany, <info at intevation.de>
+# Copyright 2007, 2008, 2010 Intevation GmbH, Germany, <info at intevation.de>
 # 
 # This file is part of mpuls WASKA (CoMPUter-based case fiLeS - 
 # Web-Anwendungs-Server fuer Kompetenzagenturen).
@@ -48,6 +48,36 @@
 
 log = logging.getLogger(__name__)
 
+def get_remindlist():
+    # FIXME: This function always returns maxsavetimelist even though it
+    # apparently was meant to return a combined list of maxsavetimelist
+    # and caseremindlist for case managers.
+    maxsavetimelist = MaxSaveTimeReminderOverview()
+    caseremindlist = CaseReminderOverview()
+    if h.hasRole(['cm_ka']):
+        #caseremindlist.join(maxsavetimelist)
+        caseremindlist.sort()
+        remindlist = caseremindlist
+    else:
+        remindlist = maxsavetimelist
+    remindlist = maxsavetimelist
+    return remindlist
+
+def get_newslist(user):
+    return NewsList(user)
+
+def get_case_appointments():
+    caseapp = CaseAppointmentOverview()
+    if h.hasRole(['cm_ka']):
+        caseremindlist = get_remindlist()
+        caseapp.join(caseremindlist)
+        caseapp.sort()
+    return caseapp
+
+def get_global_appointments():
+    return GlobalAppointmentOverview()
+
+
 MARK_NEWS_AS_READ_CONFIRM = u"""Nachricht als gelesen markieren"""
 MARK_NEWS_AS_READ_CONFIRM_TEXT = u"""Wollen Sie die Nachricht wirklich als gelesen markieren? Sie wird dadurch dauerhaft aus der Übersicht entfernt."""
 
@@ -59,53 +89,26 @@
     @checkRole(('admin_ka', 'cm_ka', 'pb_ka', 'pt_dlr'))
     def start(self):
         user = session['USER_AUTHORIZED']
-        if config.get('evaluation_server', '0') == '1': 
-        # On evaluation server do not try to find out which cases are saved
-        # longer than allowed. This would be a real performance killer and
-        # cases are anonymized anyway
-            pass
-        else:
-            # Get list of cases which were not edited longer than the allowed max
-            # savetime
-            maxsavetimelist   = MaxSaveTimeReminderOverview()
-            caseremindlist    = CaseReminderOverview()
-            if h.hasRole(['cm_ka']):
-                 #caseremindlist.join(maxsavetimelist)
-                 caseremindlist.sort()
-                 c.remindlist  = caseremindlist
-            else:
-                c.remindlist  = maxsavetimelist 
-            c.remindlist  = maxsavetimelist 
-            # Load case and global appointments
-            caseapp           = CaseAppointmentOverview()
-            globalapp         = GlobalAppointmentOverview()
-            # As we want to display both kind of app. we need to join the lists and
-            # sort them
-            if h.hasRole(['cm_ka']):
-                caseapp.join(caseremindlist)
-                caseapp.sort()
-                c.appointmentlist = caseapp
-            c.globalappointmentlist = globalapp
 
-            #find out if there are cases with errors
-            #Search inconsistencys on dates
-            #search_str1 = "state:1;state:2;state:4;state:5;bad:1;bad:2;bad:3;bad:4;bad:5;bad:6;bad:7;own:%s" % user.id
-            #Search inconsistencys on phases but ignore older cases. 
-            #search_str2 = "state:1;state:2;state:4;bad:clearing_start;bad:clearing_ende;bad:beratung_start;bad:beratung_ende;bad:cm_start;bad:cm_ende;bad:nachbetreuung_start;bad:nachbetreuung_ende;only_cases_after:'%s';own:%s" % (INCONSISTENCY_CHECK_AFTER, user.id)
-            #error_cases1 = Set(c.id for c in CaseOverview().search(search_str1))
-            #error_cases2 = Set(c.id for c in CaseOverview().search(search_str2))
-            #c.num_error_cases = len(error_cases1.union(error_cases2))
+        # LOAD REMINDERS (maxsavetime)
+        if g.mpuls_config.is_enabled('case-module', 'reminders'):
+            log.debug('Loading reminder list')
+            c.remindlist = get_remindlist()
 
-            #if c.num_error_cases > 0:
-            #    session['hascaseerrors'] = True
-            #else:
-            #    session['hascaseerrors'] = False
-            session['hascaseerrors'] = False
-            session.save()
+        # LOAD APPOINTMENTS
+        if g.mpuls_config.is_enabled('module', 'appointments'):
+            # Global appointments
+            log.debug('Loading global appointment list')
+            c.globalappointmentlist = get_global_appointments()
+        if g.mpuls_config.is_enabled('case-module', 'appointments'):
+            # Case appointments
+            log.debug('Loading case appointment list')
+            c.appointmentlist = get_case_appointments()
 
         # LOAD NEWS
-        c.news = NewsList(user)
-        #c.news = [] 
+        if g.mpuls_config.is_enabled('module', 'news'):
+            log.debug('Loading news list')
+            c.news = get_newslist(user)
         return render('/start/start.mako')
 
     def markNewsAsRead(self, id, confirmed=0):



More information about the Mpuls-commits mailing list