Add meeting duration parameter

We currently hardcode the meeting duration to be one hour. This change
allows the user to specify an optional meeting duration (in minutes)
for shorter or longer meetings.

Change-Id: Ib41d56abc0e866ca50e45469e7cd57d726b053df
This commit is contained in:
stephane 2015-02-25 13:38:25 -08:00 committed by Tony Breeds
parent afc3819c80
commit 9d78fc35a6
5 changed files with 44 additions and 4 deletions

View File

@ -110,6 +110,7 @@ Each meeting consists of:
* ``schedule``: a list of schedule each consisting of
* ``time``: time string in UTC
* ``duration``: duration of the meeting in minutes
* ``day``: the day of week the meeting takes place
* ``irc``: the irc room in which the meeting is held
* ``frequency``: frequent occurrence of the meeting

View File

@ -67,9 +67,7 @@ class Yaml2IcalCalendar(icalendar.Calendar):
# add recurrence rule
event.add('rrule', sch.recurrence.rrule())
# add meeting length
# TODO(jotan): determine duration to use for OpenStack meetings
event.add('duration', datetime.timedelta(hours=1))
event.add('duration', datetime.timedelta(minutes=sch.duration))
# add event to calendar
self.add_component(event)

View File

@ -39,6 +39,7 @@ class Schedule(object):
self.project = meeting.project
self.filefrom = meeting.filefrom
# mandatory: time, day, irc, freq, recurrence
try:
self.utc = sched_yaml['time']
self.time = datetime.datetime.strptime(sched_yaml['time'], '%H%M')
@ -52,6 +53,16 @@ class Schedule(object):
"attribute '{0}'".format(e.args[0]))
raise
# optional: duration
if 'duration' in sched_yaml:
try:
self.duration = int(sched_yaml['duration'])
except ValueError:
raise ValueError("Could not parse 'duration' (%s) in %s" %
(sched_yaml['duration'], self.filefrom))
else:
self.duration = 60
if self.day not in DATES.keys():
raise ValueError("'%s' is not a valid day of the week")
@ -59,7 +70,8 @@ class Schedule(object):
# deal with meetings that start on day1 and end on day2.
self.meeting_start = datetime.datetime.combine(DATES[self.day],
self.time.time())
self.meeting_end = (self.meeting_start + datetime.timedelta(hours=1))
self.meeting_end = (self.meeting_start +
datetime.timedelta(minutes=self.duration))
if self.day == 'Sunday' and self.meeting_end.strftime("%a") == 'Mon':
self.meeting_start = self.meeting_start - ONE_WEEK
self.meeting_end = self.meeting_end - ONE_WEEK

View File

@ -161,3 +161,18 @@ chair: Joe Developer
description: >
Weekly long meeting for Subteam project.
"""
MEETING_WITH_DURATION = """
project: OpenStack Subteam 8 Meeting
schedule:
- time: '1200'
duration: 30
day: Wednesday
irc: openstack-meeting
frequency: weekly
chair: Shannon Stacker
description: >
Weekly short meeting for Subteam project.
agenda: |
* Debate whether this should be a longer meeting
"""

View File

@ -75,3 +75,17 @@ class MeetingTestCase(unittest.TestCase):
self.should_be_conflicting(
sample_data.MEETING_MONDAY_LATE,
sample_data.MEETING_TUESDAY_EARLY)
def test_meeting_duration(self):
m = meeting.load_meetings(sample_data.MEETING_WITH_DURATION)[0]
self.assertEqual(30, m.schedules[0].duration)
m = meeting.load_meetings(sample_data.WEEKLY_MEETING)[0]
self.assertEqual(60, m.schedules[0].duration)
def test_short_meeting_conflicts(self):
self.should_be_conflicting(
sample_data.WEEKLY_MEETING,
sample_data.MEETING_WITH_DURATION)
self.should_not_conflict(
sample_data.CONFLICTING_WEEKLY_MEETING,
sample_data.MEETING_WITH_DURATION)