Repository :
http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
---------------------------------------------------------------
commit 74b6823669125acecf195d4eabce360176d3fd32
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 13:44:32 2012 +0100
Improve the agenda_is_free function
When adding a meeting, re should check that there are no meetings already running for
both the start and the end time.
---------------------------------------------------------------
fedocal/fedocallib/__init__.py | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/fedocal/fedocallib/__init__.py b/fedocal/fedocallib/__init__.py
index 30b6fe2..1863c85 100644
--- a/fedocal/fedocallib/__init__.py
+++ b/fedocal/fedocallib/__init__.py
@@ -369,7 +369,7 @@ def get_future_regular_meeting_of_user(session, username,
def agenda_is_free(session, calendar, meeting_date,
- time_start):
+ time_start, time_stop):
"""Check if there is already someting planned in this agenda at that
time.
@@ -377,9 +377,12 @@ def agenda_is_free(session, calendar, meeting_date,
:arg calendar: the name of the calendar of interest.
:arg meeting_date: the date of the meeting (as Datetime object)
:arg time_start: the time at which the meeting starts (as int)
+ :arg time_stop: the time at which the meeting stops (as int)
"""
- meetings = Meeting.get_by_time(session, calendar, meeting_date,
+ meetings = Meeting.at_time(session, calendar, meeting_date,
time_start)
+ meetings.extend(Meeting.at_time(session, calendar, meeting_date,
+ time_stop))
if not meetings:
return True
else:
@@ -567,12 +570,13 @@ def add_meeting(session, calendarobj, fas_user,
tzone, 'UTC')
free_time = agenda_is_free(session, calendarobj,
- meeting_date, meeting_time_start.time())
+ meeting_date, meeting_time_start.time(),
+ meeting_time_stop.time())
if not bool(calendarobj.calendar_multiple_meetings) and \
not bool(free_time):
raise InvalidMeeting(
- 'The start time you have entered is already occupied.')
+ 'The start or end time you have entered is already occupied.')
reminder = None
if remind_when and remind_who: