@@ -4445,6 +4445,73 @@ def upcoming_ical(request):
44454445 response ['Content-Disposition' ] = 'attachment; filename="upcoming.ics"'
44464446 return response
44474447
4448+ def render_important_dates_ical (meetings , request ):
4449+ """Generate important dates using the icalendar library"""
4450+ cal = Calendar ()
4451+ cal .add ("prodid" , "-//IETF//datatracker.ietf.org ical importantdates//EN" )
4452+ cal .add ("version" , "2.0" )
4453+ cal .add ("method" , "PUBLISH" )
4454+
4455+ for meeting in meetings :
4456+ for important_date in meeting .important_dates :
4457+ event = Event ()
4458+ event .add ("uid" , f"ietf-{ meeting .number } -{ important_date .name_id } -"
4459+ f"{ important_date .date .isoformat ()} " )
4460+ event .add ("summary" , f"IETF { meeting .number } : { important_date .name .name } " )
4461+ event .add ("class" , "PUBLIC" )
4462+
4463+ if not important_date .midnight_cutoff :
4464+ event .add ("dtstart" , important_date .date )
4465+ else :
4466+ event .add ("dtstart" , datetime .datetime .combine (
4467+ important_date .date ,
4468+ datetime .time (23 , 59 , 0 , tzinfo = pytz .UTC ))
4469+ )
4470+
4471+ event .add ("transp" , "TRANSPARENT" )
4472+ event .add ("dtstamp" , meeting .cached_updated )
4473+ description_lines = [important_date .name .desc ]
4474+ if important_date .name .slug in ('openreg' , 'earlybird' ):
4475+ description_lines .append (
4476+ "Register here: https://www.ietf.org/how/meetings/register/" )
4477+ if important_date .name .slug == 'opensched' :
4478+ description_lines .append ("To request a Working Group session, use the "
4479+ "IETF Meeting Session Request Tool:" )
4480+ description_lines .append (f"{ request .scheme } ://{ request .get_host ()} "
4481+ f"{ reverse ('ietf.meeting.views_session_request.list_view' )} " )
4482+ description_lines .append ("If you are working on a BOF request, it is "
4483+ "highly recommended to tell the IESG" )
4484+ description_lines .
append (
"now by sending an email to [email protected] " 4485+ "to get advance help with the request." )
4486+ if important_date .name .slug == 'cutoffwgreq' :
4487+ description_lines .append ("To request a Working Group session, use the "
4488+ "IETF Meeting Session Request Tool:" )
4489+ description_lines .append (f"{ request .scheme } ://{ request .get_host ()} "
4490+ f"{ reverse ('ietf.meeting.views_session_request.list_view' )} " )
4491+ if important_date .name .slug == 'cutoffbofreq' :
4492+ description_lines .append ("To request a BOF, please see instructions on "
4493+ "Requesting a BOF:" )
4494+ description_lines .append ("https://www.ietf.org/how/bofs/bof-procedures/" )
4495+ if important_date .name .slug == 'idcutoff' :
4496+ description_lines .append ("Upload using the I-D Submission Tool:" )
4497+ description_lines .append (f"{ request .scheme } ://{ request .get_host ()} "
4498+ f"{ reverse ('ietf.submit.views.upload_submission' )} " )
4499+ if important_date .name .slug in (
4500+ 'draftwgagenda' ,
4501+ 'revwgagenda' ,
4502+ 'procsub' ,
4503+ 'revslug'
4504+ ):
4505+ description_lines .append ("Upload using the Meeting Materials "
4506+ "Management Tool:" )
4507+ description_lines .append (f"{ request .scheme } ://{ request .get_host ()} "
4508+ f"{ reverse ('ietf.meeting.views.materials' ,
4509+ kwargs = {'num' : meeting .number })} " )
4510+
4511+ event .add ("description" , "\n " .join (description_lines ))
4512+ cal .add_component (event )
4513+
4514+ return cal .to_ical ().decode ("utf-8" )
44484515
44494516def upcoming_json (request ):
44504517 '''Return Upcoming meetings in json format'''
@@ -5063,11 +5130,8 @@ def important_dates(request, num=None, output_format=None):
50635130 if output_format == 'ics' :
50645131 preprocess_meeting_important_dates (meetings )
50655132
5066- ics = render_to_string ('meeting/important_dates.ics' , {
5067- 'meetings' : meetings ,
5068- }, request = request )
5069- # icalendar response file should have '\r\n' line endings per RFC5545
5070- response = HttpResponse (parse_ical_line_endings (ics ), content_type = 'text/calendar' )
5133+ response = HttpResponse (render_important_dates_ical (meetings , request ),
5134+ content_type = 'text/calendar' )
50715135 response ['Content-Disposition' ] = 'attachment; filename="important-dates.ics"'
50725136 return response
50735137
0 commit comments