22
33from django .contrib .syndication .views import Feed
44
5- from datetime import timedelta
5+ from datetime import datetime , timedelta , timezone
66from typing import TYPE_CHECKING
77
88from icalendar import Calendar , Event
@@ -18,12 +18,12 @@ class ActivityFeed(Feed):
1818 link = "https://commitfest.postgresql.org/"
1919
2020 def __init__ (self , activity , cf , * args , ** kwargs ):
21- super (ActivityFeed , self ).__init__ (* args , ** kwargs )
21+ super ().__init__ (* args , ** kwargs )
2222 self .activity = activity
2323 if cf :
2424 self .cfid = cf .id
2525 self .title = self .description = (
26- "PostgreSQL Commitfest {0 } Activity Log" . format ( cf . name )
26+ f "PostgreSQL Commitfest { cf . name } Activity Log"
2727 )
2828 else :
2929 self .cfid = None
@@ -53,24 +53,32 @@ def calendar(commitfests: Iterable[CommitFest]) -> Calendar:
5353 Build an RFC 5545 iCalendar document with one all-day VEVENT per
5454 commitfest, covering its start and end date.
5555 """
56- calendar = Calendar .new (
57- prodid = "-//PostgreSQL Commitfest//commitfest.postgresql.org//EN" ,
58- name = "PostgreSQL Commitfests" ,
59- description = "Start and end dates of PostgreSQL Commitfests" ,
60- method = "PUBLISH" ,
61- )
62-
56+ # We use add() instead of the nicer Calendar.new()/Event.new() helpers,
57+ # because those were only added in icalendar 7.0.0, and production uses
58+ # the version packaged by Debian trixie, which is 6.0.1.
59+ name = "PostgreSQL Commitfests"
60+ description = "Start and end dates of PostgreSQL Commitfests"
61+ calendar = Calendar ()
62+ calendar .add ("version" , "2.0" )
63+ calendar .add ("prodid" , "-//PostgreSQL Commitfest//commitfest.postgresql.org//EN" )
64+ calendar .add ("method" , "PUBLISH" )
65+ calendar .add ("description" , description )
66+ calendar .add ("x-wr-caldesc" , description )
67+ calendar .add ("name" , name )
68+ calendar .add ("x-wr-calname" , name )
69+
70+ now = datetime .now (timezone .utc )
6371 for cf in commitfests :
64- event = Event . new (
65- uid = f"commitfest-{ cf .name } @commitfest.postgresql.org" ,
66- summary = cf . title ,
67- start = cf .startdate ,
68- # DTEND is exclusive for all-day events, so add a day to make the
69- # last day of the commitfest show up as included on the calendar.
70- end = cf . enddate + timedelta ( days = 1 ),
71- description = f"Status: { cf .statusstring } " ,
72- url = f"https://commitfest.postgresql.org/ { cf .id } /" ,
73- )
72+ event = Event ()
73+ event . add ( " uid" , f"commitfest-{ cf .name } @commitfest.postgresql.org" )
74+ event . add ( "dtstamp" , now )
75+ event . add ( "summary" , cf .title )
76+ event . add ( "dtstart" , cf . startdate )
77+ # DTEND is exclusive for all- day events, so add a day to make the
78+ # last day of the commitfest show up as included on the calendar.
79+ event . add ( "dtend" , cf .enddate + timedelta ( days = 1 ))
80+ event . add ( "description" , f"Status: { cf .statusstring } " )
81+ event . add ( "url" , f"https://commitfest.postgresql.org/ { cf . id } /" )
7482 calendar .add_component (event )
7583
7684 return calendar
0 commit comments