[Mpuls-commits] r3357 - wasko/trunk/waskoweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Aug 10 15:20:40 CEST 2010


Author: roland
Date: 2010-08-10 15:20:39 +0200 (Tue, 10 Aug 2010)
New Revision: 3357

Modified:
   wasko/trunk/waskoweb/controllers/formularpage.py
Log:
fixed problem when case has no data yet

Modified: wasko/trunk/waskoweb/controllers/formularpage.py
===================================================================
--- wasko/trunk/waskoweb/controllers/formularpage.py	2010-08-10 12:44:54 UTC (rev 3356)
+++ wasko/trunk/waskoweb/controllers/formularpage.py	2010-08-10 13:20:39 UTC (rev 3357)
@@ -103,10 +103,15 @@
                             FROM master_tbl_view
                             WHERE id = %s''' % (case_id))
             case_data = cur.fetchall()[0]
-            max_date = max([date for date in case_data[:3] if date != None])
-            date_extension_1 = case_data[2]
-            date_extension_2 = case_data[3]
-            first_date = case_data[0]
+            dates = [date for date in case_data[:3] if date != None]
+            if dates:
+                max_date = max([date for date in case_data[:3] if date != None])
+                date_extension_1 = case_data[2]
+                date_extension_2 = case_data[3]
+                first_date = case_data[0]
+            else:
+                first_date = max_date = datetime.date.today()
+                date_extension_1 = date_extension_2 = datetime.date.today()
             time_delta = max_date - first_date
             
             # Maximum of 18 months with 2 extensions
@@ -117,9 +122,8 @@
             elif (date_extension_1 != None and date_extension_2 == None
                 and time_delta.days > 15*31):
                 max_time_delta = datetime.timedelta(15*31)
-            # 12 months
-            elif (date_extension_1 == None and date_extension_2 == None
-                and time_delta.days > 12*31):
+            # Everything else, 12 months
+            else:
                 max_time_delta = datetime.timedelta(12*31)
             
             appointment_factory = CaseAppointmentFactory()



More information about the Mpuls-commits mailing list