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
This commit is contained in:
parent
e89a272661
commit
c61d1d1c2f
|
@ -4,6 +4,7 @@ import pytz, datetime
|
|||
from urlparse import urljoin
|
||||
import copy
|
||||
import os
|
||||
import re
|
||||
|
||||
import debug
|
||||
|
||||
|
@ -193,6 +194,21 @@ class Meeting(models.Model):
|
|||
ScheduledSession.objects.create(schedule = sched,
|
||||
timeslot = ts)
|
||||
|
||||
def vtimezone(self):
|
||||
if self.time_zone:
|
||||
try:
|
||||
tzfn = os.path.join(settings.TZDATA_ICS_PATH, self.time_zone + ".ics")
|
||||
if os.path.exists(tzfn):
|
||||
with open(tzfn) as tzf:
|
||||
icstext = tzf.read()
|
||||
vtimezone = re.search("(?sm)(\nBEGIN:VTIMEZONE.*\nEND:VTIMEZONE\n)", icstext).group(1).strip()
|
||||
if vtimezone:
|
||||
vtimezone += "\n"
|
||||
return vtimezone
|
||||
except IOError:
|
||||
pass
|
||||
return ''
|
||||
|
||||
class Meta:
|
||||
ordering = ["-date", ]
|
||||
|
||||
|
@ -1177,3 +1193,14 @@ class Session(models.Model):
|
|||
return "BOF" if self.group.state.slug in ["bof", "bof-conc"] else "WG"
|
||||
else:
|
||||
return ""
|
||||
|
||||
def ical_status(self):
|
||||
if self.status.slug == 'canceled': # sic
|
||||
return "CANCELLED"
|
||||
elif (datetime.date.today() - self.meeting.date) > datetime.timedelta(days=5):
|
||||
# this is a bit simpleminded, better would be to look at the
|
||||
# time(s) of the timeslot(s) of the official meeting schedule.
|
||||
return "CONFIRMED"
|
||||
else:
|
||||
return "TENTATIVE"
|
||||
|
Loading…
Reference in a new issue