Merged [4226] from adam@nostrum.com:

Updated agenda.ics to use new data model. Also, tons more efficient. Additionally, the description field now includes links to relevant meeting materials.
 - Legacy-Id: 4267
Note: SVN reference [4226] has been migrated to Git commit 740487d69f
This commit is contained in:
Henrik Levkowetz 2012-04-05 21:36:00 +00:00
commit 484eb75241
3 changed files with 45 additions and 35 deletions

View file

@ -47,6 +47,7 @@ class Meeting(models.Model):
# Look at the time of 8 o'clock sunday, rather than 0h sunday, to get
# the right time after a possible summer/winter time change.
return pytz.timezone(self.time_zone).localize(datetime.datetime.combine(self.date, datetime.time(8, 0))).strftime("%z")
def get_meeting_date (self,offset):
return self.date + datetime.timedelta(days=offset)

View file

@ -5,6 +5,7 @@ import datetime
import os
import re
import tarfile
import pytz
from tempfile import mkstemp
@ -428,7 +429,6 @@ def get_meeting (num=None):
return meeting
def week_view(request, num=None):
#timeslots, update, meeting, venue, ads, plenaryw_agenda, plenaryt_agenda = agenda_info(num)
meeting = get_meeting(num)
timeslots = TimeSlot.objects.filter(meeting = meeting.number)
@ -437,24 +437,39 @@ def week_view(request, num=None):
{"timeslots":timeslots,"render_types":["Session","Other","Break","Plenary"]}, context_instance=RequestContext(request))
def ical_agenda(request, num=None):
timeslots, update, meeting, venue, ads, plenaryw_agenda, plenaryt_agenda = agenda_info(num)
wgs = IETFWG.objects.filter(status=IETFWG.ACTIVE).order_by('group_acronym__acronym')
rgs = IRTF.objects.all().order_by('acronym')
areas = Area.objects.filter(status=Area.ACTIVE).order_by('area_acronym__acronym')
# The timezone situation here remains tragic, but I've burned
# hours trying to figure out how to get the information I need
# in python. I can do this trivially in perl with its Ical module,
# but the icalendar module in python seems staggeringly less
# capable. There might be a path to success here, but I'm not
# completely convinced. So I'm going to spend some time
# working on more urgent matters for now. -Adam
meeting = get_meeting(num)
q = request.META.get('QUERY_STRING','') or ""
filter = q.lower().split(',');
include = set(filter)
now = datetime.datetime.utcnow()
include_types = ["Plenary","Other"]
exclude = []
for slot in timeslots:
for session in slot.sessions():
if session.area() == '' or session.area().find('plenary') > 0 or (session.area().lower() in include):
filter.append(session.acronym())
# Process the special flags.
for item in include:
if item[0] == '-':
exclude.append(item[1:])
if item[0] == '~':
include_types.append(item[1:2].upper()+item[2:])
timeslots = TimeSlot.objects.filter(Q(meeting = meeting.number),
Q(type__name__in = include_types) |
Q(session__group__acronym__in = filter) |
Q(session__group__parent__acronym__in = filter)
).exclude(Q(session__group__isnull = False),
Q(session__group__acronym__in = exclude) |
Q(session__group__parent__acronym__in = exclude))
return HttpResponse(render_to_string("meeting/agendaREDESIGN.ics" if settings.USE_DB_REDESIGN_PROXY_CLASSES else "meeting/agenda.ics",
{"filter":set(filter), "timeslots":timeslots, "update":update, "meeting":meeting, "venue":venue, "ads":ads,
"plenaryw_agenda":plenaryw_agenda, "plenaryt_agenda":plenaryt_agenda,
"now":now},
{"timeslots":timeslots, "meeting":meeting },
RequestContext(request)), mimetype="text/calendar")
def csv_agenda(request, num=None):

View file

@ -9,27 +9,21 @@ TZOFFSETTO:{{meeting.time_zone_offset}}
TZNAME:{{meeting.time_zone}}
DTSTART:19700101T000000
END:STANDARD
END:VTIMEZONE
{% endif %}{% for slot in timeslots %}{% ifchanged %}{% if slot.session_name and slot.break_info %}BEGIN:VEVENT
UID:ietf-{{meeting.num}}-break-{{slot.time_id}}
SUMMARY:{{slot.break_info.name}}
{% if venue.break_area_name and slot.break_info.show_break_location %}LOCATION:{{venue.break_area_name}}
END:VTIMEZONE{% endif %}{% for slot in timeslots %}
BEGIN:VEVENT
UID:ietf-{{slot.meeting.number}}-{{slot.pk}}
SUMMARY:{% if slot.session.name %}{{slot.session.name}}{% else %}{% if slot.type.name == "Break" %}{{slot.name}}{% else %}{{slot.session.group.acronym|upper}} - {{slot.session.group.name}}{% endif%}{%endif%}
{% if slot.show_location %}LOCATION:{{slot.get_location}}
{% endif %}STATUS:TENTATIVE
CLASS:PUBLIC
DTSTART{% if meeting.time_zone %};TZID="{{meeting.time_zone}}"{%endif%}:{{ slot.meeting_date|date:"Ymd" }}T{{slot.break_info.time_desc|slice:":4"}}00
DTEND{% if meeting.time_zone %};TZID="{{meeting.time_zone}}"{%endif%}:{{ slot.meeting_date|date:"Ymd" }}T{{slot.break_info.time_desc|slice:"5:9"}}00
DTSTAMP:{{ now|date:"Ymd" }}T{{ now|date:"His" }}Z
END:VEVENT
{% endif %}{% endifchanged %}{% for session in slot.sessions %}{%for f in filter%}{%ifequal f session.acronym%}BEGIN:VEVENT
UID:ietf-{{meeting.num}}-{{session.acronym}}-{{session.pk}}
SUMMARY:{% if session.area %}{% ifnotequal session.area "1plenary" %}{{session.acronym|upper}} - {% endifnotequal %}{% endif %}{{session.acronym_name}}
LOCATION:{{session.room_id.room_name}}
STATUS:TENTATIVE
CLASS:PUBLIC
DTSTART{% if meeting.time_zone %};TZID="{{meeting.time_zone}}"{%endif%}:{{ slot.meeting_date|date:"Ymd" }}T{{slot.time_desc|slice:":4"}}00
DTEND{% if meeting.time_zone %};TZID="{{meeting.time_zone}}"{%endif%}:{{ slot.meeting_date|date:"Ymd" }}T{{slot.time_desc|slice:"5:9"}}00
DTSTAMP:{{ now|date:"Ymd" }}T{{ now|date:"His" }}Z
{% if session.description %}DESCRIPTION:
{{ session.description|escapejs }}
{% endif %}END:VEVENT
{%endifequal%}{%endfor%}{% endfor %}{% endfor %}END:VCALENDAR{% endautoescape %}
DTSTART{% if meeting.time_zone %};TZID="{{meeting.time_zone}}"{%endif%}:{{ slot.time|date:"Ymd" }}T{{slot.time|date:"Hi"}}00
DTEND{% if meeting.time_zone %};TZID="{{meeting.time_zone}}"{%endif%}:{{ slot.end_time|date:"Ymd" }}T{{slot.end_time|date:"Hi"}}00
DTSTAMP:{{ slot.modified|date:"Ymd" }}T{{ slot.modified|date:"His" }}Z
{% if slot.session.agenda %}URL:http://www.ietf.org{{slot.session.agenda.get_absolute_url}}
DESCRIPTION:{{slot.name}}\n{% if slot.session.agenda_note %}
Note: {{slot.session.agenda_note}}\n{% endif %}{% for material in slot.session.materials.all %}
\n{{material.type}}{% if material.type.name != "Agenda" %}
({{material.title}}){% endif %}:
http://www.ietf.org{{material.get_absolute_url}}\n{% endfor %}
{% endif %}END:VEVENT{% endfor %}
END:VCALENDAR{% endautoescape %}