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

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 2 11:36:36 CEST 2012


Author: roland
Date: 2012-10-02 11:36:36 +0200 (Tue, 02 Oct 2012)
New Revision: 6087

Modified:
   base/trunk/mpulsweb/model/appointment.py
Log:
Add a new job percentage reminder (2066-5)

Modified: base/trunk/mpulsweb/model/appointment.py
===================================================================
--- base/trunk/mpulsweb/model/appointment.py	2012-10-02 09:35:58 UTC (rev 6086)
+++ base/trunk/mpulsweb/model/appointment.py	2012-10-02 09:36:36 UTC (rev 6087)
@@ -37,6 +37,7 @@
 from mpulsweb.lib.translation import _
 from mpulsweb.model.case import MpulsCaseOverview
 from mpulsweb.model.agencysettings import Agency
+from mpulsweb.model.percentage import JobPercentage
 from mpulsweb.controllers.case_overview import default_phases 
 
 log = logging.getLogger(__name__)
@@ -701,4 +702,56 @@
                                            case.id, type)
         return appointment
 
+
+
+
+
+
+
+
+
+# Job percentage
+
+class JobPercentageReminderOverview(AppointmentOverview):
+    """
+    Calculates the agency's job percentage and creates a reminder if it passes
+    a threshold.
+    """
+    
+    def __init__(self):    
+        self.appointment_list = []
+        
+        # Calculate the job percentage
+        percentage = JobPercentage()    
+        percentage_value = percentage.calulate_percentage()
+        
+        threshold_higher = float(g.mpuls_config.get('job_percentage', 'threshold_higher'))
+        threshold_lower = float(g.mpuls_config.get('job_percentage', 'threshold_lower'))
+        
+        make_appointment = False
+        
+        # Check for the higher threshold first (more important)
+        if percentage_value >= threshold_higher:
+            make_appointment = True
+            reminder_title = _('You have exeeded the job percentage threshold')
+            reminder_description = _('Please check yout cases, you have exceeded the threshold \
+            by a wide margin.')
+        
+        # Check for the second threshold
+        if not make_appointment and percentage_value >= threshold_lower:
+            make_appointment = True
+            reminder_title = _('You have exeeded the job percentage threshold')
+            reminder_description = _('Please check yout cases, you have exceeded the threshold.')
+        
+        # There is something to report, make an appointment
+        if make_appointment:
+            factory = CaseAppointmentFactory()
+
+            
+            appointment = factory.createByData(title = reminder_title,
+                                desc = reminder_description,
+                                type = 2)
+
+            self.appointment_list.append(appointment)
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8:



More information about the Mpuls-commits mailing list