[Mpuls-commits] r5043 - in base/trunk: . mpulsweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue May 31 13:25:43 CEST 2011
Author: ludwig
Date: 2011-05-31 13:25:42 +0200 (Tue, 31 May 2011)
New Revision: 5043
Modified:
base/trunk/ChangeLog
base/trunk/mpulsweb/model/appointment.py
Log:
Issue1972: Added handling of only date or only time case in creation of events
Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog 2011-05-31 11:01:28 UTC (rev 5042)
+++ base/trunk/ChangeLog 2011-05-31 11:25:42 UTC (rev 5043)
@@ -1,5 +1,11 @@
2011-05-31 Ludwig Reiter <ludwig.reiter at intevation.de>
+ * mpulsweb/model/appointment.py:
+ Issue1972: 2 new cases for event date/times are handled:
+ "only enddate", "only endtime". This improves the create event dialog.
+
+2011-05-31 Ludwig Reiter <ludwig.reiter at intevation.de>
+
* mpulsweb/templates/home/remindlist.mako:
Issue882: Different behaviour of reminders and automatic reminders.
Reminders are shown with just a show button and this button opens the
Modified: base/trunk/mpulsweb/model/appointment.py
===================================================================
--- base/trunk/mpulsweb/model/appointment.py 2011-05-31 11:01:28 UTC (rev 5042)
+++ base/trunk/mpulsweb/model/appointment.py 2011-05-31 11:25:42 UTC (rev 5043)
@@ -292,32 +292,46 @@
H, M = (0, 0)
return datetime(int(Y), int(m), int(d), int(H), int(M))
- def _convert2Datetime(self, mdate, mtime):
+ def _convert2Datetime(self, mdate, mtime, ddate=None, dtime=None):
log.debug("%s, %s" % (mtime, type(mtime)))
try:
-
+ date, time = (False, False)
try:
y = mdate.year
m = mdate.month
d = mdate.day
+ date = True
except:
- return None
+ date = False
- # If no time id provided set to 00:00:00
try:
H = mtime.hour
M = mtime.minute
S = mtime.second
+ time = True
except:
- H = 0
- M = 0
- S = 0
- return datetime(y, m, d, H, M, S)
+ time = False
+ if date and time:
+ return datetime(y, m, d, H, M, S)
+ elif date:
+ H = dtime.hour
+ M = dtime.minute
+ S = dtime.second
+ return datetime(y, m, d, H, M, S)
+ elif time:
+ y = ddate.year
+ m = ddate.month
+ d = ddate.day
+ return datetime(y, m, d, H, M, S)
+
+ return None
+
except Exception, e:
log.error(e)
return None
+
def getStartDate(self):
return self.start_date
@@ -336,16 +350,16 @@
self.title = data.get('title', self.title)
self.type = data.get('type', self.type)
- # Set date
self.start_date = self._convert2Datetime(data.get('start_date'),
data.get('start_time'))
end_date = self._convert2Datetime(data.get('end_date'),
- data.get('end_time'))
+ data.get('end_time'),
+ data.get('start_date'),
+ data.get('start_time'))
- # If no enddate is given assume a 24h appointment
+ # If convert of enddate fail
if not end_date:
- # Add 24 hours to startdate
self.end_date = self.start_date + timedelta(hours=24)
else:
self.end_date = end_date
More information about the Mpuls-commits
mailing list