aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlban Gruin2018-01-24 20:08:18 +0100
committerAlban Gruin2018-01-24 20:08:18 +0100
commit465c1c13f2e5a77f296de92d4b5b14cf319c68c5 (patch)
tree9a6aeac860f0550f64c0db89d4fd73609f4acc70
parente2bc777f7f988cba945c027aaa27d98aa3913a71 (diff)
Annulation de la conversion des heures au bon fuseau dans l’ICS.
Pour cela, on avait besoin d’insérer un objet vTimezone dans l’en-tête du fichier, ce qui est assez fastidieux. À la place, on met une valeur x-wr-timezone dans les en-têtes. Ajout de valeurs calscale, method, x-wr-calname et x-wr-caldesc aux ICS. Revert "Bon fuseau horaire dans les ICS." This reverts commit e2bc777f7f988cba945c027aaa27d98aa3913a71.
-rw-r--r--feeds.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/feeds.py b/feeds.py
index bcbf7f9..2f6c586 100644
--- a/feeds.py
+++ b/feeds.py
@@ -21,7 +21,7 @@ from django.db.models.functions import ExtractWeek, ExtractYear
from django.template import loader
from django.urls import reverse
from django.utils.feedgenerator import Atom1Feed, SyndicationFeed
-from django.utils.timezone import localtime
+from django.utils.timezone import get_current_timezone_name
from icalendar import Calendar, Event
@@ -40,6 +40,11 @@ class IcalFeedGenerator(SyndicationFeed):
calendar = Calendar()
calendar.add("prodid", "-//celcatsanitizer//NONSGML v1.0//EN")
calendar.add("version", "2.0")
+ calendar.add("calscale", "GREGORIAN")
+ calendar.add("method", "PUBLISH")
+ calendar.add("x-wr-timezone", get_current_timezone_name())
+ calendar.add("x-wr-calname", self.feed["title"])
+ calendar.add("x-wr-caldesc", self.feed["title"])
self.write_events(calendar)
outfile.write(calendar.to_ical())
@@ -87,12 +92,15 @@ class IcalFeed(Feed):
def item_extra_kwargs(self, item):
return {"uid": "{0}@celcatsanitizer".format(item.id),
- "dtstart": localtime(item.begin),
- "dtend": localtime(item.end),
- "dtstamp": localtime(item.last_update),
+ "dtstart": item.begin,
+ "dtend": item.end,
+ "dtstamp": item.last_update,
"summary": self.item_summary(item),
"location": format_rooms(item.rooms.all())}
+ def title(self, obj):
+ return "Emploi du temps du groupe {0}".format(obj)
+
class IcalOnlyOneFeed(IcalFeed):
def items(self, obj):