start_date now supported in schedules

start_date defines when a meeting series begins.  start_date
is used in lieu of the current date when rebuilding the calendar.

This will ultimately let us move away from needing to have
biweekly-odd and biweekly-even.

I also added an example.yaml with a start_date

Change-Id: I0c5f6e5951b6c15b949f599182f48aa132b76abb
This commit is contained in:
Brian (bex) Exelbierd 2015-06-24 20:39:53 +02:00
parent 81c242b7e0
commit a8c789d4b4
7 changed files with 72 additions and 2 deletions

View File

@ -122,6 +122,8 @@ Each meeting consists of:
* ``time``: time string in UTC [MANDATORY]
* ``duration``: duration of the meeting in minutes; defaults to 60
* ``start_date``: the date the first meeting takes place on or after.
Format `YYYYMMDD`, all values must be zero-padded.
* ``day``: the day of week the meeting takes place [MANDATORY]
* ``irc``: the irc room in which the meeting is held [MANDATORY]
* ``frequency``: frequent occurrence of the meeting [MANDATORY]

13
meetings/example2.yaml Normal file
View File

@ -0,0 +1,13 @@
project: Example Start Date Team Meeting
agenda_url: http://agenda.com/
project_url: http://project.com
schedule:
- time: '1600'
duration: 45
start_date: 20150801
day: Thursday
irc: openstack-meeting
frequency: weekly
chair: John Doe
description: >
If you're interested in Example, we have a 45 minute long weekly meeting for you to attend.

View File

@ -63,8 +63,8 @@ class Yaml2IcalCalendar(icalendar.Calendar):
event.add('description', ical_descript)
# get starting date
start_date = datetime.datetime.utcnow()
next_meeting = sch.recurrence.next_occurence(start_date, sch.day)
next_meeting = sch.recurrence.next_occurence(sch.start_date,
sch.day)
next_meeting_date = datetime.datetime(next_meeting.year,
next_meeting.month,
next_meeting.day,

View File

@ -53,6 +53,17 @@ class Schedule(object):
"attribute '{0}'".format(e.args[0]))
raise
# optional: start_date defaults to the current date if not present
if 'start_date' in sched_yaml:
try:
self.start_date = datetime.datetime.strptime(
str(sched_yaml['start_date']), '%Y%m%d')
except ValueError:
raise ValueError("Could not parse 'start_date' (%s) in %s" %
(sched_yaml['start_date'], self.filefrom))
else:
self.start_date = datetime.datetime.utcnow()
# optional: duration
if 'duration' in sched_yaml:
try:

View File

@ -176,3 +176,19 @@ description: >
agenda: |
* Debate whether this should be a longer meeting
"""
MEETING_WITH_START_DATE = """
project: OpenStack Subteam 8 Meeting
schedule:
- time: '1200'
duration: 30
day: Thursday
start_date: 20150801
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

@ -0,0 +1,28 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import datetime
import unittest
from yaml2ical import meeting
from yaml2ical import recurrence
from yaml2ical.tests import sample_data
class Meeting_RecurrenceTestCase(unittest.TestCase):
def test_next_meeting_start_date(self):
m = meeting.load_meetings(sample_data.MEETING_WITH_START_DATE)[0]
self.assertEqual(
datetime.datetime(2015, 8, 6, 0, 0),
recurrence.WeeklyRecurrence().next_occurence(
m.schedules[0].start_date, m.schedules[0].day))