[Mpuls-commits] r1903 - wasko/branches/2.0/mpulsweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Mar 8 10:40:49 CET 2010
Author: torsten
Date: 2010-03-08 10:40:49 +0100 (Mon, 08 Mar 2010)
New Revision: 1903
Modified:
wasko/branches/2.0/mpulsweb/model/appointment.py
Log:
* mpulsweb/model/appointment.py (Appointment._convertStr2Date):
Deleted. Not used anywherenow
* mpulsweb/model/appointment.py (Appointment._convert2Datetime): New
convert function which combines date and time to datetime.
* mpulsweb/model/appointment.py (Appointment.setData): Use convert
function
Modified: wasko/branches/2.0/mpulsweb/model/appointment.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/appointment.py 2010-03-08 09:38:40 UTC (rev 1902)
+++ wasko/branches/2.0/mpulsweb/model/appointment.py 2010-03-08 09:40:49 UTC (rev 1903)
@@ -28,6 +28,8 @@
# Torsten Irländer <torsten.irlaender at intevation.de>
#
+import logging
+
from datetime import datetime, timedelta
import mpulsweb.lib.helpers as h
@@ -107,6 +109,8 @@
WHERE id = %(id)s
"""
+log = logging.getLogger(__name__)
+
class AppointmentFactory:
def loadById(self, id):
@@ -283,6 +287,32 @@
H, M = (0, 0)
return datetime(int(Y), int(m), int(d), int(H), int(M))
+ def _convert2Datetime(self, mdate, mtime):
+ log.debug("%s, %s" % (mtime, type(mtime)))
+ try:
+
+ try:
+ y = mdate.year
+ m = mdate.month
+ d = mdate.day
+ except:
+ return None
+
+ # If no time id provided set to 00:00:00
+ try:
+ H = mtime.hour
+ M = mtime.minute
+ S = mtime.second
+ except:
+ H = 0
+ M = 0
+ S = 0
+ return datetime(y,m,d,H,M,S)
+
+ except Exception, e:
+ log.error(e)
+ return None
+
def getStartDate(self):
return self.start_date
@@ -302,19 +332,12 @@
self.type = data.get('type', self.type)
# Set date
- sdate = "%s %s" % (data.get('start_date'), data.get('start_time'))
- self.start_date = self._convertStr2Date(sdate)
+ self.start_date = self._convert2Datetime(
+ data.get('start_date'), data.get('start_time'))
- ## If not end_date is given, than end_date is equal to start_date
- #if not data.get('end_date') or not data.get('end_time'):
- # self.end_date = self.start_date
- #else:
- # edate = "%s %s" % (data.get('end_date'), data.get('end_time'))
- # self.end_date = self._convertStr2Date(edate)
+ self.end_date = self._convert2Datetime(
+ data.get('end_date'), data.get('end_time'))
- edate = "%s %s" % (data.get('end_date'), data.get('end_time'))
- self.end_date = self._convertStr2Date(edate)
-
self.description = data.get('description', self.description)
self.case_id = data.get('case_id', self.case_id)
@@ -331,6 +354,8 @@
cur.execute(self.store_sql, fields)
conn.commit()
return True
+ except Exception, e:
+ log.error(e)
finally:
db.recycleConnection(conn, cur)
return False
More information about the Mpuls-commits
mailing list