Repository :
http://git.fedorahosted.org/cgit/fedocal.git
On branch : master
---------------------------------------------------------------
commit a88f19e9707386700f4f2e99cdd3bb854258e38b
Author: Pierre-Yves Chibon <pingou(a)pingoured.fr>
Date: Sat Nov 17 13:42:09 2012 +0100
Change back the get_by_time functions as it was and add a at_time function
The get_by_time allows you to retrieve all the meetings within a time period while
the at_time function allows you to retrieve the meeting occuring at a given time.
This is used to check when adding a meeting if the time slot is free.
---------------------------------------------------------------
fedocal/fedocallib/model.py | 17 ++++++++++++++---
1 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/fedocal/fedocallib/model.py b/fedocal/fedocallib/model.py
index 510d002..f0e738d 100644
--- a/fedocal/fedocallib/model.py
+++ b/fedocal/fedocallib/model.py
@@ -298,15 +298,26 @@ class Meeting(BASE):
(Meeting.meeting_region == region)).all()
@classmethod
- def get_by_time(cls, session, calendar, meetingdate, start_time):
+ def get_by_time(cls, session, calendar, meetingdate, start_time,
+ stop_time):
""" Retrieve the list of meetings for a given date and between
two times.
"""
return session.query(cls).filter(and_
(Meeting.calendar == calendar),
(Meeting.meeting_date == meetingdate),
- (Meeting.meeting_time_start <= start_time),
- (Meeting.meeting_time_stop > start_time)).all()
+ (Meeting.meeting_time_start >= start_time),
+ (Meeting.meeting_time_stop <= stop_time)).all()
+
+ @classmethod
+ def at_time(cls, session, calendar, meetingdate, t_time):
+ """ Returns the meeting occuring at this specifict time point.
+ """
+ return session.query(cls).filter(and_
+ (Meeting.calendar == calendar),
+ (Meeting.meeting_date == meetingdate),
+ (Meeting.meeting_time_start <= t_time),
+ (Meeting.meeting_time_stop > t_time)).all()
@classmethod
def get_past_meeting_of_user(cls, session, username, start_date):