Add Adhoc frequency
For the irc-meetings we would like to list the possiblity of a meeting but not actually formally schedule it. This change allows for an AdHoc meeting which is essentially a noop in the ical generation Change-Id: I843b5b3f2a6e5a74b85b13b86c8d16125a1ac7c7
This commit is contained in:
parent
cee12f20b1
commit
f2f98285ef
@ -81,6 +81,11 @@ class Yaml2IcalCalendar(icalendar.Calendar):
|
||||
# get starting date
|
||||
next_meeting = sch.recurrence.next_occurence(sch.start_date,
|
||||
sch.day)
|
||||
# NOTE(aschultz): to handle adhoc meetings, we check to make
|
||||
# sure there is a next meeting before trying to add it to the
|
||||
# the calendar
|
||||
if next_meeting is None:
|
||||
return
|
||||
next_meeting_date = datetime.datetime(next_meeting.year,
|
||||
next_meeting.month,
|
||||
next_meeting.day,
|
||||
|
@ -78,8 +78,32 @@ class BiWeeklyRecurrence(object):
|
||||
return "Every two weeks (on %s weeks)" % self.style
|
||||
|
||||
|
||||
class AdhocRecurrence(object):
|
||||
"""Meetings occuring as needed.
|
||||
|
||||
Effectively this is a noop recurrance as next_occurance is always None
|
||||
"""
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def next_occurence(self, current_date, day):
|
||||
"""Calculate the next adhoc meeting.
|
||||
|
||||
:param current_date: the current date
|
||||
:param day: scheduled day of the meeting
|
||||
:returns: datetime object of next meeting
|
||||
"""
|
||||
return None
|
||||
|
||||
def rrule(self):
|
||||
return {'freq': 'adhoc', 'interval': 0}
|
||||
|
||||
def __str__(self):
|
||||
return "Occurs as needed, no fixed schedule."
|
||||
|
||||
supported_recurrences = {
|
||||
'weekly': WeeklyRecurrence(),
|
||||
'biweekly-odd': BiWeeklyRecurrence(style='odd'),
|
||||
'biweekly-even': BiWeeklyRecurrence(),
|
||||
'adhoc': AdhocRecurrence(),
|
||||
}
|
||||
|
@ -258,3 +258,17 @@ chair: Shannon Stacker
|
||||
description: >
|
||||
Weekly short meeting for Subteam project.
|
||||
"""
|
||||
|
||||
# adhoc meeting
|
||||
ADHOC_MEETING = """
|
||||
project: OpenStack Random Meeting
|
||||
schedule:
|
||||
- time: '1200'
|
||||
day: Monday
|
||||
start_date: 20150801
|
||||
irc: openstack-meeting
|
||||
frequency: adhoc
|
||||
chair: Shannon Stacker
|
||||
description: >
|
||||
Adhoc random meeting for Subteam project.
|
||||
"""
|
||||
|
@ -116,6 +116,13 @@ class MeetingTestCase(unittest.TestCase):
|
||||
for p in patterns:
|
||||
self.assertNotEqual(None, p.match(cal_str))
|
||||
|
||||
def test_adhoc_meeting(self):
|
||||
meeting_yaml = sample_data.ADHOC_MEETING
|
||||
m = meeting.load_meetings(meeting_yaml)[0]
|
||||
cal = ical.Yaml2IcalCalendar()
|
||||
cal.add_meeting(m)
|
||||
self.assertEqual(cal, ical.Yaml2IcalCalendar())
|
||||
|
||||
def test_skip_meeting_missing_skip_date(self):
|
||||
self.assertRaises(KeyError,
|
||||
meeting.load_meetings,
|
||||
|
@ -37,3 +37,8 @@ class RecurrenceTestCase(unittest.TestCase):
|
||||
self.assertEqual(
|
||||
datetime.datetime(2014, 10, 15, 2, 47, 28, 832666),
|
||||
self.next_meeting(recurrence.BiWeeklyRecurrence(style='even')))
|
||||
|
||||
def test_next_adhoc(self):
|
||||
self.assertEqual(
|
||||
None,
|
||||
self.next_meeting(recurrence.AdhocRecurrence()))
|
||||
|
Loading…
x
Reference in New Issue
Block a user