Skip to content

Commit c61d1d1

Browse files
committed
Provided new methods Meeting.vtimezone() which return a vtimezone stanza for
ical files, based on the timezone setting for a meeting, fetched from a pre- generated file; and Session.ical_status(), which provides a string appropriate for use in ical STATUS: entries. - Legacy-Id: 6536
1 parent e89a272 commit c61d1d1

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

ietf/meeting/models.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from urlparse import urljoin
55
import copy
66
import os
7+
import re
78

89
import debug
910

@@ -193,6 +194,21 @@ def create_all_timeslots(self):
193194
ScheduledSession.objects.create(schedule = sched,
194195
timeslot = ts)
195196

197+
def vtimezone(self):
198+
if self.time_zone:
199+
try:
200+
tzfn = os.path.join(settings.TZDATA_ICS_PATH, self.time_zone + ".ics")
201+
if os.path.exists(tzfn):
202+
with open(tzfn) as tzf:
203+
icstext = tzf.read()
204+
vtimezone = re.search("(?sm)(\nBEGIN:VTIMEZONE.*\nEND:VTIMEZONE\n)", icstext).group(1).strip()
205+
if vtimezone:
206+
vtimezone += "\n"
207+
return vtimezone
208+
except IOError:
209+
pass
210+
return ''
211+
196212
class Meta:
197213
ordering = ["-date", ]
198214

@@ -1177,3 +1193,14 @@ def type(self):
11771193
return "BOF" if self.group.state.slug in ["bof", "bof-conc"] else "WG"
11781194
else:
11791195
return ""
1196+
1197+
def ical_status(self):
1198+
if self.status.slug == 'canceled': # sic
1199+
return "CANCELLED"
1200+
elif (datetime.date.today() - self.meeting.date) > datetime.timedelta(days=5):
1201+
# this is a bit simpleminded, better would be to look at the
1202+
# time(s) of the timeslot(s) of the official meeting schedule.
1203+
return "CONFIRMED"
1204+
else:
1205+
return "TENTATIVE"
1206+

0 commit comments

Comments
 (0)