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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Mar 2 14:44:24 CET 2011


Author: torsten
Date: 2011-03-02 14:44:23 +0100 (Wed, 02 Mar 2011)
New Revision: 4745

Modified:
   base/trunk/mpulsweb/model/appointment.py
Log:
* mpulsweb/model/appointment.py: Fixed formatting of SQL-querys


Modified: base/trunk/mpulsweb/model/appointment.py
===================================================================
--- base/trunk/mpulsweb/model/appointment.py	2011-03-02 13:04:35 UTC (rev 4744)
+++ base/trunk/mpulsweb/model/appointment.py	2011-03-02 13:44:23 UTC (rev 4745)
@@ -94,8 +94,12 @@
 
 class CaseAppointmentFactory(AppointmentFactory):
 
-    GET_CASE_APPOINTMENT_SQL = """SELECT id, master_id, sdatum, edatum, name,
-    beschreibung, art FROM ka_fall_termine_tbl_view WHERE id = %(id)s """
+    GET_CASE_APPOINTMENT_SQL = """
+    SELECT 
+    id, master_id, sdatum, edatum, name,
+    beschreibung, art 
+    FROM ka_fall_termine_tbl_view 
+    WHERE id = %(id)s """
     CREATE_CASE_APPOINTMENT_SQL = "SELECT create_fall_termin_ds(%(id)s)"
 
     def __init__(self):
@@ -106,8 +110,12 @@
 
 class CaseReminderFactory(AppointmentFactory):
 
-    GET_CASE_APPOINTMENT_SQL = """SELECT id, master_id, sdatum, edatum, name,
-    beschreibung, art FROM ka_fall_termine_tbl_view WHERE id = %(id)s """
+    GET_CASE_APPOINTMENT_SQL = """
+    SELECT 
+    id, master_id, sdatum, edatum, name,
+    beschreibung, art 
+    FROM ka_fall_termine_tbl_view 
+    WHERE id = %(id)s"""
     CREATE_CASE_APPOINTMENT_SQL = "SELECT create_fall_termin_ds(%(id)s)"
 
     def __init__(self):
@@ -118,9 +126,12 @@
 
 class GlobalAppointmentFactory(AppointmentFactory):
 
-    GET_GLOBAL_APPOINTMENT_SQL = """SELECT id, master_id, sdatum, edatum,
-    name, beschreibung, art FROM ka_global_termine_tbl_view WHERE id = %(id)s
-    """
+    GET_GLOBAL_APPOINTMENT_SQL = """
+    SELECT 
+    id, master_id, sdatum, edatum,
+    name, beschreibung, art 
+    FROM ka_global_termine_tbl_view 
+    WHERE id = %(id)s"""
     CREATE_GLOBAL_APPOINTMENT_SQL = "SELECT create_global_termin_ds()"
 
     def __init__(self):
@@ -159,17 +170,26 @@
 
 class CaseAppointmentOverview(AppointmentOverview):
 
-    GET_CASE_APPOINTMENTLIST_SQL = """SELECT id, master_id, sdatum, edatum,
-    name, beschreibung, art FROM ka_fall_termine_tbl_view WHERE master_id =
-    %(id)s AND coalesce(edatum, sdatum)::date+1 >= %(date)s::date AND art = 0
-    ORDER BY sdatum """
+    GET_CASE_APPOINTMENTLIST_SQL = """
+    SELECT 
+    id, master_id, sdatum, edatum,
+    name, beschreibung, art 
+    FROM ka_fall_termine_tbl_view 
+    WHERE master_id = %(id)s AND coalesce(edatum, sdatum)::date+1 >= %(date)s::date 
+    AND art = 0
+    ORDER BY sdatum"""
 
-    GET_ALLCASES_APPOINTMENTLIST_SQL = """SELECT a.id, a.master_id, a.sdatum,
-    a.edatum, a.name, a.beschreibung, a.art FROM ka_fall_termine_tbl_view a
-    JOIN master_tbl_view m ON m.id = a.master_id JOIN ka_status_tbl_view s ON
-    m.id = s.master_id WHERE coalesce(edatum, sdatum)::date+1 >= %(date)s::date
-    AND art = 0 AND m.bearbeiter_id = %(editor)s AND s.status = 1 ORDER BY
-    sdatum """
+    GET_ALLCASES_APPOINTMENTLIST_SQL = """
+    SELECT a.id, a.master_id, a.sdatum,
+    a.edatum, a.name, a.beschreibung, a.art 
+    FROM ka_fall_termine_tbl_view a
+    JOIN master_tbl_view m ON m.id = a.master_id 
+    JOIN ka_status_tbl_view s ON m.id = s.master_id 
+    WHERE coalesce(edatum, sdatum)::date+1 >= %(date)s::date
+    AND art = 0 
+    AND m.bearbeiter_id = %(editor)s 
+    AND s.status = 1 ORDER BY
+    sdatum"""
 
     def __init__(self, caseid=None):
         afactory = CaseAppointmentFactory()
@@ -187,9 +207,13 @@
 
 class GlobalAppointmentOverview(AppointmentOverview):
 
-    GET_GLOBAL_APPOINTMENTLIST_SQL = """SELECT id, master_id, sdatum, edatum,
-    name, beschreibung, art FROM ka_global_termine_tbl_view WHERE
-    coalesce(edatum, sdatum)::date+1 >= %(date)s::date ORDER BY sdatum """
+    GET_GLOBAL_APPOINTMENTLIST_SQL = """
+    SELECT 
+    id, master_id, sdatum, edatum,
+    name, beschreibung, art 
+    FROM ka_global_termine_tbl_view 
+    WHERE coalesce(edatum, sdatum)::date+1 >= %(date)s::date 
+    ORDER BY sdatum"""
 
     def __init__(self):
         afactory = GlobalAppointmentFactory()
@@ -202,15 +226,25 @@
 
 class CaseReminderOverview(AppointmentOverview):
 
-    GET_CASE_REMINDERLIST_SQL = """SELECT id, master_id, sdatum, edatum,
-    name, beschreibung, art FROM ka_fall_termine_tbl_view WHERE master_id =
-    %(id)s AND art = 1 ORDER BY sdatum """
+    GET_CASE_REMINDERLIST_SQL = """
+    SELECT 
+    id, master_id, sdatum, edatum,
+    name, beschreibung, art 
+    FROM ka_fall_termine_tbl_view 
+    WHERE master_id = %(id)s 
+    AND art = 1 
+    ORDER BY sdatum"""
 
-    GET_ALLCASES_REMINDERLIST_SQL = """SELECT a.id, a.master_id, a.sdatum,
-    a.edatum, a.name, a.beschreibung, a.art FROM ka_fall_termine_tbl_view a
-    JOIN master_tbl_view m ON m.id = a.master_id JOIN ka_status_tbl_view s ON
-    m.id = s.master_id WHERE art = 1 AND m.bearbeiter_id = %(editor)s AND
-    s.status = 1 ORDER BY sdatum """
+    GET_ALLCASES_REMINDERLIST_SQL = """
+    SELECT a.id, a.master_id, a.sdatum,
+    a.edatum, a.name, a.beschreibung, a.art 
+    FROM ka_fall_termine_tbl_view a
+    JOIN master_tbl_view m ON m.id = a.master_id 
+    JOIN ka_status_tbl_view s ON m.id = s.master_id 
+    WHERE art = 1 
+    AND m.bearbeiter_id = %(editor)s 
+    AND s.status = 1 
+    ORDER BY sdatum"""
 
     def __init__(self, caseid=None):
         afactory = CaseReminderFactory()
@@ -344,10 +378,14 @@
 class GlobalAppointment(Appointment):
 
     DELETE_GLOBAL_APPOINTMENT_SQL = "SELECT delete_global_termin_ds(%(id)s)"
-    STORE_GLOBAL_APPOINTMENT_SQL = """UPDATE ka_global_termine_tbl_view SET
-    sdatum = %(start_date)s::timestamp, edatum = %(end_date)s::timestamp, name
-    = %(title)s, beschreibung = %(description)s, art = %(type)s WHERE id =
-    %(id)s """
+    STORE_GLOBAL_APPOINTMENT_SQL = """
+    UPDATE ka_global_termine_tbl_view 
+    SET sdatum = %(start_date)s::timestamp, 
+    edatum = %(end_date)s::timestamp, 
+    name = %(title)s, 
+    beschreibung = %(description)s, 
+    art = %(type)s 
+    WHERE id = %(id)s"""
 
     def __init__(self):
         Appointment.__init__(self)
@@ -359,10 +397,14 @@
 class CaseAppointment(Appointment):
 
     DELETE_CASE_APPOINTMENT_SQL = "SELECT delete_fall_termin_ds(%(id)s)"
-    STORE_CASE_APPOINTMENT_SQL = """UPDATE ka_fall_termine_tbl_view SET sdatum
-    = %(start_date)s::timestamp, edatum = %(end_date)s::timestamp, name =
-    %(title)s, beschreibung = %(description)s, art = %(type)s WHERE id = %(id)s
-    """
+    STORE_CASE_APPOINTMENT_SQL = """
+    UPDATE ka_fall_termine_tbl_view 
+    SET sdatum = %(start_date)s::timestamp, 
+    edatum = %(end_date)s::timestamp, 
+    name = %(title)s, 
+    beschreibung = %(description)s, 
+    art = %(type)s 
+    WHERE id = %(id)s"""
 
     def __init__(self):
         Appointment.__init__(self)
@@ -381,29 +423,49 @@
 
 class MaxSaveTimeReminderOverview(AppointmentOverview):
 
-    GET_OLDFINISHED_CASES = """SELECT m.id, s.zugriff,
-    getLastCaseAppointment(m.id) as last_date FROM master_tbl_view m JOIN
-    ka_status_tbl_view s ON s.master_id = m.id WHERE s.status <> 5 AND
-    m.bearbeiter_id = %%(editor)s AND extract(day from now()-s.zugriff) >
-    %%(maxdays)s AND phase in (%s) AND (%s) """
+    GET_OLDFINISHED_CASES = """
+    SELECT m.id, s.zugriff,
+    getLastCaseAppointment(m.id) as last_date 
+    FROM master_tbl_view m 
+    JOIN ka_status_tbl_view s ON s.master_id = m.id 
+    WHERE s.status <> 5 
+    AND m.bearbeiter_id = %%(editor)s 
+    AND extract(day from now()-s.zugriff) > %%(maxdays)s 
+    AND phase in (%s) 
+    AND (%s)"""
 
-    GET_OLDFINISHED_CASES_4_ADMIN = """SELECT m.id, s.zugriff,
-    getLastCaseAppointment(m.id) as last_date FROM master_tbl_view m JOIN
-    ka_status_tbl_view s ON s.master_id = m.id WHERE s.status <> 5 AND
-    extract(day from now()-s.zugriff) > %%(maxdays)s AND phase in (%s) AND
-    (%s)"""
+    GET_OLDFINISHED_CASES_4_ADMIN = """
+    SELECT m.id, s.zugriff, 
+    getLastCaseAppointment(m.id) as last_date 
+    FROM master_tbl_view m 
+    JOIN ka_status_tbl_view s ON s.master_id = m.id 
+    WHERE s.status <> 5 
+    AND extract(day from now()-s.zugriff) > %%(maxdays)s 
+    AND phase in (%s) 
+    AND (%s)"""
 
-    GET_OLDACTIVE_CASES = """SELECT m.id, s.zugriff,
-    getLastCaseAppointment(m.id) AS last_date FROM (SELECT * FROM
-    ka_status_tbl_view WHERE zugriff < now() - interval '1 day' * %%(maxdays)s
-    AND status <> 5) s JOIN master_tbl_view m ON m.id = s.master_id WHERE phase
-    in (%s) AND (%s) AND m.bearbeiter_id = %%(editor)s """
+    GET_OLDACTIVE_CASES = """
+    SELECT m.id, s.zugriff,
+    getLastCaseAppointment(m.id) AS last_date 
+    FROM (
+        SELECT * FROM ka_status_tbl_view 
+        WHERE zugriff < now() - interval '1 day' * %%(maxdays)s
+        AND status <> 5) s 
+    JOIN master_tbl_view m ON m.id = s.master_id 
+    WHERE phase in (%s) 
+    AND (%s) 
+    AND m.bearbeiter_id = %%(editor)s"""
 
-    GET_OLDACTIVE_CASES_4_ADMIN = """SELECT m.id, s.zugriff,
-    getLastCaseAppointment(m.id) AS last_date FROM (SELECT * FROM
-    ka_status_tbl_view WHERE zugriff < now() - interval '1 day' * %%(maxdays)s
-    AND status <> 5) s JOIN master_tbl_view m ON m.id = s.master_id WHERE phase
-    in (%s) AND (%s) """
+    GET_OLDACTIVE_CASES_4_ADMIN = """
+    SELECT m.id, s.zugriff,
+    getLastCaseAppointment(m.id) AS last_date 
+    FROM (
+        SELECT * FROM ka_status_tbl_view 
+        WHERE zugriff < now() - interval '1 day' * %%(maxdays)s 
+        AND status <> 5) s
+    JOIN master_tbl_view m ON m.id = s.master_id 
+    WHERE phase in (%s) 
+    AND (%s)"""
 
     def __init__(self):
         self.appointment_list = []



More information about the Mpuls-commits mailing list