[Mpuls-commits] r3833 - in waska/trunk/waskaweb: controllers model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 30 15:15:45 CEST 2010


Author: roland
Date: 2010-09-30 15:15:44 +0200 (Thu, 30 Sep 2010)
New Revision: 3833

Modified:
   waska/trunk/waskaweb/controllers/logbook.py
   waska/trunk/waskaweb/model/case.py
Log:
G121: fixed formatting, removed debug lines

Modified: waska/trunk/waskaweb/controllers/logbook.py
===================================================================
--- waska/trunk/waskaweb/controllers/logbook.py	2010-09-30 12:49:27 UTC (rev 3832)
+++ waska/trunk/waskaweb/controllers/logbook.py	2010-09-30 13:15:44 UTC (rev 3833)
@@ -38,11 +38,9 @@
 class LogbookController(LogbookController):
     @checkRole(('cm_ka'))
     def index(self, id):
-        print "Updating logbook data in formed..."
         return self.overview(id)
 
     def overview(self, id):
-        print "Overview. Calculating..."
         sort, order = get_sort(request.params)
         id = self._checkInt(id)
 
@@ -65,6 +63,9 @@
             conn = db.getConnection()
             
             # Decide here whether to update or not.
+            # Roland: it is not yet clear till we will do the automatic update
+            # of the statistics (e.g. till X required fields are filled)
+            
             #sql_load = "SELECT xyz FROM master_tbl_view WHERE id = %s" % id
             #cur = conn.cursor()
             #cur.execute(sql_load)
@@ -75,16 +76,21 @@
             
             sql_update = 'UPDATE master_tbl_view SET '
             # Set the data for the different types
-            #print type_statistics
             for logbook_type in type_statistics['types']:
                 if logbook_type['typ'] != None:
-                    tagebuch_kontakte = 'tagebuch_anzahl_kontakte_%s' % formed_suffix.get(logbook_type['typ'], 'ka')
-                    tagebuch_aufwand  = 'tagebuch_aufwand_stunden_%s' % formed_suffix.get(logbook_type['typ'], 'ka')
-                    tagebuch_prozent  = 'tagebuch_prozent_%s' % formed_suffix.get(logbook_type['typ'], 'ka')
+                    tagebuch_kontakte = 'tagebuch_anzahl_kontakte_%s' % \
+                                 formed_suffix.get(logbook_type['typ'], 'ka')
+                    tagebuch_aufwand  = 'tagebuch_aufwand_stunden_%s' % \
+                                 formed_suffix.get(logbook_type['typ'], 'ka')
+                    tagebuch_prozent  = 'tagebuch_prozent_%s' % \
+                                formed_suffix.get(logbook_type['typ'], 'ka')
     
-                    sql_update = sql_update + ' %(kontakte)s = %%(%(kontakte)s)s, ' % {'kontakte': tagebuch_kontakte}
-                    sql_update = sql_update + ' %(aufwand)s = %%(%(aufwand)s)s, ' % {'aufwand': tagebuch_aufwand}
-                    sql_update = sql_update + ' %(prozent)s = %%(%(prozent)s)s, ' % {'prozent': tagebuch_prozent}
+                    sql_update = sql_update + ' %(kontakte)s = %%(%(kontakte)s)s, ' % \
+                                        {'kontakte': tagebuch_kontakte}
+                    sql_update = sql_update + ' %(aufwand)s = %%(%(aufwand)s)s, ' % \
+                                        {'aufwand': tagebuch_aufwand}
+                    sql_update = sql_update + ' %(prozent)s = %%(%(prozent)s)s, ' % \
+                                        {'prozent': tagebuch_prozent}
 
                     new_data[tagebuch_kontakte] = logbook_type['amount']
                     new_data[tagebuch_aufwand] = logbook_type['time']
@@ -92,24 +98,21 @@
             
             # Set the data for the general statistics
             
-            sql_update = sql_update + 'tagebuch_anzahl_kontakte_gesamt = %s, ' % type_statistics['total']['amount']
-            sql_update = sql_update + 'tagebuch_aufwand_stunden_gesamt = %s, ' % type_statistics['total']['time']
-            sql_update = sql_update + 'tagebuch_prozent_gesamt = %s ' % type_statistics['total']['percent']
+            sql_update = sql_update + 'tagebuch_anzahl_kontakte_gesamt = %s, ' % \
+                                            type_statistics['total']['amount']
+            sql_update = sql_update + 'tagebuch_aufwand_stunden_gesamt = %s, ' % \
+                                            type_statistics['total']['time']
+            sql_update = sql_update + 'tagebuch_prozent_gesamt = %s ' % \
+                                            type_statistics['total']['percent']
             
             #now put all together
             sql_update = sql_update + ' WHERE id = %(id)s'
             
+            # Roland: this will change, once it is decided how and when we will
+            # update the statistics. Till then, just check for the existence of
+            # 'types'
             #if update_case:
             if type_statistics['types']:
-                #pass
-                #sql_update = """
-                    #UPDATE master_tbl_view
-                    #SET
-                        #tagebuch_anzahl_kontakte_ka = %(tagebuch_anzahl_kontakte_ka)s,
-                        #tagebuch_aufwand_stunden_ka = %(tagebuch_aufwand_stunden_ka)s,
-                        #tagebuch_prozent_ka = %(tagebuch_prozent_ka)s
-                    #WHERE id = %(id)s""" % new_data
-                print sql_update % new_data
                 cur = conn.cursor()
                 cur.execute(sql_update, new_data)
                 conn.commit()

Modified: waska/trunk/waskaweb/model/case.py
===================================================================
--- waska/trunk/waskaweb/model/case.py	2010-09-30 12:49:27 UTC (rev 3832)
+++ waska/trunk/waskaweb/model/case.py	2010-09-30 13:15:44 UTC (rev 3833)
@@ -48,18 +48,6 @@
     name_kompetenzagentur = %(ka_name)s
 WHERE id = %(id)s"""
 
-#INIT_CASE_SQL = """
-#UPDATE master_tbl_view
-#SET
-    #vorname = %(vorname)s,
-    #name = %(nachname)s,
-    #name_kompetenzagentur = %(ka_name)s,
-    #tagebuch_anzahl_kontakte_ka = %(tagebuch_anzahl_kontakte_ka)s,
-    #tagebuch_aufwand_stunden_ka = %(tagebuch_aufwand_stunden_ka)s,
-    #tagebuch_prozent_ka = %(tagebuch_prozent_ka)s
-#WHERE id = %(id)s"""
-
-
 SET_EDITOR_SQL = """SELECT set_case_editor(%(userid)s, %(caseid)s)"""
 SET_EDITOR_NAME_SQL = """
 SELECT set_case_editor_name(%(firstname)s, %(lastname)s, %(caseid)s)"""
@@ -91,9 +79,6 @@
                 'vorname': user.first_name,
                 'nachname': user.last_name,
                 'ka_name': agency.getName(),
-                #'tagebuch_anzahl_kontakte_ka': 1,
-                #'tagebuch_aufwand_stunden_ka': 0,
-                #'tagebuch_prozent_ka': 100,
                 'id': int(id)
                 }
             conn = db.getConnection()



More information about the Mpuls-commits mailing list