Make the upcoming meetings iCal group the IETF meetings into one

block and add important dates. Also fix a couple of bugs found by
running the generated .ics through the icalendar.org validator.
 - Legacy-Id: 18434
This commit is contained in:
Ole Laursen 2020-08-28 12:28:29 +00:00
parent 0aa0f7d4e2
commit 8759339e65
6 changed files with 67 additions and 44 deletions

View file

@ -1931,7 +1931,6 @@ class InterimTests(TestCase):
make_meeting_test_data(create_interims=True)
url = urlreverse("ietf.meeting.views.upcoming")
today = datetime.date.today()
add_event_info_to_session_qs(Session.objects.filter(meeting__type='interim', group__acronym='mars')).filter(current_status='apprw').first()
mars_interim = add_event_info_to_session_qs(Session.objects.filter(meeting__type='interim', meeting__date__gt=today, group__acronym='mars')).filter(current_status='sched').first().meeting
ames_interim = add_event_info_to_session_qs(Session.objects.filter(meeting__type='interim', meeting__date__gt=today, group__acronym='ames')).filter(current_status='canceled').first().meeting
r = self.client.get(url)
@ -1944,19 +1943,28 @@ class InterimTests(TestCase):
self.check_interim_tabs(url)
def test_upcoming_ical(self):
make_meeting_test_data(create_interims=True)
meeting = make_meeting_test_data(create_interims=True)
populate_important_dates(meeting)
url = urlreverse("ietf.meeting.views.upcoming_ical")
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
today = datetime.date.today()
mars_interim = add_event_info_to_session_qs(Session.objects.filter(meeting__type='interim', meeting__date__gt=today, group__acronym='mars')).filter(current_status='sched').first().meeting
ames_interim = add_event_info_to_session_qs(Session.objects.filter(meeting__type='interim', meeting__date__gt=today, group__acronym='ames')).filter(current_status='canceled').first().meeting
self.assertContains(r, mars_interim.number)
self.assertContains(r, ames_interim.number)
self.assertContains(r, 'IETF 72')
self.assertEqual(r.get('Content-Type'), "text/calendar")
self.assertEqual(r.content.count(b'UID'), 7)
self.assertEqual(r.content.count(b'UID'), 3 + meeting.importantdate_set.count())
# check filtered output
url = url + '?filters=mars'
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
self.assertEqual(r.get('Content-Type'), "text/calendar")
# print r.content
self.assertEqual(r.content.count(b'UID'), 2)
self.assertEqual(r.content.count(b'UID'), 2 + meeting.importantdate_set.count())
def test_upcoming_json(self):

View file

@ -560,3 +560,11 @@ def swap_meeting_schedule_timeslot_assignments(schedule, source_timeslots, targe
if not swapped:
for a in lts_assignments:
a.delete()
def preprocess_meeting_important_dates(meetings):
for m in meetings:
m.cached_updated = m.updated()
m.important_dates = m.importantdate_set.prefetch_related("name")
for d in m.important_dates:
d.midnight_cutoff = "UTC 23:59" in d.name.name

View file

@ -81,6 +81,7 @@ from ietf.meeting.utils import data_for_meetings_overview
from ietf.meeting.utils import preprocess_constraints_for_meeting_schedule_editor
from ietf.meeting.utils import diff_meeting_schedules, prefetch_schedule_diff_objects
from ietf.meeting.utils import swap_meeting_schedule_timeslot_assignments
from ietf.meeting.utils import preprocess_meeting_important_dates
from ietf.message.utils import infer_message
from ietf.secr.proceedings.utils import handle_upload_file
from ietf.secr.proceedings.proc_utils import (get_progress_stats, post_process, import_audio_files,
@ -3246,7 +3247,7 @@ def upcoming_ical(request):
assignments = list(SchedTimeSessAssignment.objects.filter(
schedule__in=[m.schedule_id for m in meetings] + [m.schedule.base_id for m in meetings if m.schedule],
session__in=[s.pk for m in meetings for s in m.sessions],
session__in=[s.pk for m in meetings for s in m.sessions if m.type_id != 'ietf'],
timeslot__time__gte=today,
).order_by(
'schedule__meeting__date', 'session__type', 'timeslot__time'
@ -3270,17 +3271,16 @@ def upcoming_ical(request):
a.session = sessions.get(a.session_id) or a.session
a.session.ical_status = ical_session_status(a)
# gather vtimezones
vtimezones = set()
for meeting in meetings:
if meeting.vtimezone():
vtimezones.add(meeting.vtimezone())
vtimezones = ''.join(vtimezones)
# handle IETFs separately
ietfs = [m for m in meetings if m.type_id == 'ietf']
preprocess_meeting_important_dates(ietfs)
# icalendar response file should have '\r\n' line endings per RFC5545
response = render_to_string('meeting/upcoming.ics', {
'vtimezones': vtimezones,
'assignments': assignments})
'vtimezones': ''.join({meeting.vtimezone() for meeting in meetings if meeting.vtimezone()}),
'assignments': assignments,
'ietfs': ietfs,
}, request=request)
response = re.sub("\r(?!\n)|(?<!\r)\n", "\r\n", response)
response = HttpResponse(response, content_type='text/calendar')
@ -3603,11 +3603,7 @@ def important_dates(request, num=None, output_format=None):
meetings.append(future_meeting)
if output_format == 'ics':
for m in meetings:
m.cached_updated = m.updated()
m.important_dates = m.importantdate_set.prefetch_related("name")
for d in m.important_dates:
d.midnight_cutoff = "UTC 23:59" in d.name.name
preprocess_meeting_important_dates(meetings)
ics = render_to_string('meeting/important_dates.ics', {
'meetings': meetings,

View file

@ -2,25 +2,4 @@
VERSION:2.0
METHOD:PUBLISH
PRODID:-//IETF//datatracker.ietf.org ical importantdates//EN
{% for meeting in meetings %}{% for d in meeting.important_dates %}BEGIN:VEVENT
UID:ietf-{{ meeting.number }}-{{ d.name_id }}-{{ d.date.isoformat }}
SUMMARY:IETF {{ meeting.number }}: {{ d.name.name }}
CLASS:PUBLIC
DTSTART{% if not d.midnight_cutoff %};VALUE=DATE{% endif %}:{{ d.date|date:"Ymd" }}{% if d.midnight_cutoff %}235900Z{% endif %}
DTSTAMP:{{ meeting.cached_updated|date:"Ymd" }}T{{ meeting.cached_updated|date:"His" }}Z
DESCRIPTION:{{ d.name.desc }} {% if first and d.name.slug == 'openreg' or first and d.name.slug == 'earlybird' %}
Register here: https://www.ietf.org/how/meetings/register/{% endif %}{% if d.name.slug == 'opensched' %}
To request a Working Group session, use the IETF Meeting Session Request Tool:
{{ request.scheme }}://{{ request.get_host}}{% url 'ietf.secr.sreq.views.main' %}
If you are working on a BoF request, it is highly recommended to tell the IESG
now by sending an email to iesg@ietf.org to get advance help with the request.{% endif %}{% if d.name.slug == 'cutoffwgreq' %}
To request a Working Group session, use the IETF Meeting Session Request Tool:
{{ request.scheme }}://{{ request.get_host }}{% url 'ietf.secr.sreq.views.main' %}{% endif %}{% if d.name.slug == 'cutoffbofreq' %}
To request a BOF, please see instructions on Requesting a BOF:
https://www.ietf.org/how/bofs/bof-procedures/{% endif %}{% if d.name.slug == 'idcutoff' %}
Upload using the ID Submission Tool:
{{ request.scheme }}://{{ request.get_host }}{% url 'ietf.submit.views.upload_submission' %}{% endif %}{% if d.name.slug == 'draftwgagenda' or d.name.slug == 'revwgagenda' or d.name.slug == 'procsub' or d.name.slug == 'revslug' %}
Upload using the Meeting Materials Management Tool:
{{ request.scheme }}://{{ request.get_host }}{% url 'ietf.meeting.views.materials' num=meeting.number %}{% endif %}
END:VEVENT
{% endfor %}{% endfor %}END:VCALENDAR{% endautoescape %}
{% for meeting in meetings %}{% include "meeting/important_dates_for_meeting.ics" %}{% endfor %}END:VCALENDAR{% endautoescape %}

View file

@ -0,0 +1,22 @@
{% for d in meeting.important_dates %}BEGIN:VEVENT
UID:ietf-{{ meeting.number }}-{{ d.name_id }}-{{ d.date.isoformat }}
SUMMARY:IETF {{ meeting.number }}: {{ d.name.name }}
CLASS:PUBLIC
DTSTART{% if not d.midnight_cutoff %};VALUE=DATE{% endif %}:{{ d.date|date:"Ymd" }}{% if d.midnight_cutoff %}235900Z{% endif %}
DTSTAMP:{{ meeting.cached_updated|date:"Ymd" }}T{{ meeting.cached_updated|date:"His" }}Z
DESCRIPTION:{{ d.name.desc }} {% if first and d.name.slug == 'openreg' or first and d.name.slug == 'earlybird' %}
Register here: https://www.ietf.org/how/meetings/register/{% endif %}{% if d.name.slug == 'opensched' %}
To request a Working Group session, use the IETF Meeting Session Request Tool:
{{ request.scheme }}://{{ request.get_host}}{% url 'ietf.secr.sreq.views.main' %}
If you are working on a BoF request, it is highly recommended to tell the IESG
now by sending an email to iesg@ietf.org to get advance help with the request.{% endif %}{% if d.name.slug == 'cutoffwgreq' %}
To request a Working Group session, use the IETF Meeting Session Request Tool:
{{ request.scheme }}://{{ request.get_host }}{% url 'ietf.secr.sreq.views.main' %}{% endif %}{% if d.name.slug == 'cutoffbofreq' %}
To request a BOF, please see instructions on Requesting a BOF:
https://www.ietf.org/how/bofs/bof-procedures/{% endif %}{% if d.name.slug == 'idcutoff' %}
Upload using the ID Submission Tool:
{{ request.scheme }}://{{ request.get_host }}{% url 'ietf.submit.views.upload_submission' %}{% endif %}{% if d.name.slug == 'draftwgagenda' or d.name.slug == 'revwgagenda' or d.name.slug == 'procsub' or d.name.slug == 'revslug' %}
Upload using the Meeting Materials Management Tool:
{{ request.scheme }}://{{ request.get_host }}{% url 'ietf.meeting.views.materials' num=meeting.number %}{% endif %}
END:VEVENT
{% endfor %}

View file

@ -8,8 +8,8 @@ SUMMARY:{% if item.session.name %}{{item.session.name|ics_esc}}{% else %}{{item.
{% if item.schedule.meeting.city %}LOCATION:{{item.schedule.meeting.city}},{{item.schedule.meeting.country}}
{% endif %}STATUS:{{item.session.ical_status}}
CLASS:PUBLIC
DTSTART{% if item.schedule.meeting.time_zone %};TZID="{{item.schedule.meeting.time_zone}}"{%endif%}:{{ item.timeslot.time|date:"Ymd" }}T{{item.timeslot.time|date:"Hi"}}00
DTEND{% if item.schedule.meeting.time_zone %};TZID="{{item.schedule.meeting.time_zone}}"{%endif%}:{{ item.timeslot.end_time|date:"Ymd" }}T{{item.timeslot.end_time|date:"Hi"}}00
DTSTART{% if item.schedule.meeting.time_zone and item.schedule.meeting.time_zone != 'UTC' %};TZID={{ item.schedule.meeting.time_zone|ics_esc }}{%endif%}:{{ item.timeslot.time|date:"Ymd" }}T{{item.timeslot.time|date:"Hi"}}00
DTEND{% if item.schedule.meeting.time_zone and item.schedule.meeting.time_zone != 'UTC' %};TZID={{ item.schedule.meeting.time_zone|ics_esc }}{%endif%}:{{ item.timeslot.end_time|date:"Ymd" }}T{{item.timeslot.end_time|date:"Hi"}}00
DTSTAMP:{{ item.timeslot.modified|date:"Ymd" }}T{{ item.timeslot.modified|date:"His" }}Z
{% if item.session.agenda %}URL:{{item.session.agenda.get_href}}
DESCRIPTION:{{item.timeslot.name|ics_esc}}\n{% if item.session.agenda_note %}
@ -18,4 +18,14 @@ DESCRIPTION:{{item.timeslot.name|ics_esc}}\n{% if item.session.agenda_note %}
({{material.title|ics_esc}}){% endif %}:
{{material.get_href}}\n{% endfor %}
{% endif %}END:VEVENT
{% endfor %}END:VCALENDAR{% endautoescape %}
{% endfor %}{% for meeting in ietfs %}BEGIN:VEVENT
UID:ietf-{{ meeting.number }}
SUMMARY:IETF {{ meeting.number }}{% if meeting.city %}
LOCATION:{{ meeting.city }},{{ meeting.country }}{% endif %}
CLASS:PUBLIC
DTSTART;VALUE=DATE{% if meeting.time_zone and meeting.time_zone != 'UTC' %};TZID={{ meeting.time_zone|ics_esc }}{% endif %}:{{ meeting.date|date:"Ymd" }}
DTEND;VALUE=DATE{% if meeting.time_zone and meeting.time_zone != 'UTC' %};TZID={{ meeting.time_zone|ics_esc }}{% endif %}:{{ meeting.end_date|date:"Ymd" }}
DTSTAMP:{{ meeting.cached_updated|date:"Ymd" }}T{{ meeting.cached_updated|date:"His" }}Z
URL:{{ request.scheme }}://{{ request.get_host }}{% url 'ietf.meeting.views.agenda' num=meeting.number %}
END:VEVENT
{% include "meeting/important_dates_for_meeting.ics" %}{% endfor %}END:VCALENDAR{% endautoescape %}