From 6f026e4f0bca3cc3bb137bc26967283510c135de Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 24 Sep 2017 14:37:09 +0200 Subject: Ajout des propriétés uid et prodid dans les iCalendar --- feeds.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/feeds.py b/feeds.py index 2dd2479..a75e60b 100644 --- a/feeds.py +++ b/feeds.py @@ -27,7 +27,7 @@ from .models import Course, Group, LastUpdate from .templatetags.rooms import format_rooms from .utils import get_current_or_next_week, get_week, group_courses -ICAL_NAMES = ["summary", "description", "location", "start", "dtstart", "dtend"] +ICAL_NAMES = ["uid", "summary", "description", "location", "start", "dtstart", "dtend"] class IcalFeedGenerator(SyndicationFeed): @@ -35,6 +35,7 @@ class IcalFeedGenerator(SyndicationFeed): def write(self, outfile, encoding): calendar = Calendar() + calendar.add("prodid", "-//celcatsanitizer//NONSGML v1.0//EN") calendar.add("version", "2.0") self.write_events(calendar) @@ -71,7 +72,8 @@ class IcalFeed(Feed): return Course.objects.get_courses_for_group(obj).order_by("begin") def item_extra_kwargs(self, item): - return {"dtstart": item.begin, + return {"uid": "{0}@celcatsanitizer".format(item.id), + "dtstart": item.begin, "dtend": item.end, "summary": item.name, "location": format_rooms(item.rooms.all())} -- cgit v1.2.1 From 0949b09c0040a66ffd1869da23a9425da891d56f Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Sun, 24 Sep 2017 15:01:59 +0200 Subject: Ajout du champ dtstamp aux fichiers iCalendar. Suppression du order_by("begin") redondant lors de la récupération des cours --- feeds.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/feeds.py b/feeds.py index a75e60b..6dfb851 100644 --- a/feeds.py +++ b/feeds.py @@ -17,6 +17,7 @@ from django.core.exceptions import ObjectDoesNotExist from django.conf import settings from django.contrib.syndication.views import Feed from django.db.models import Q +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 @@ -27,7 +28,7 @@ from .models import Course, Group, LastUpdate from .templatetags.rooms import format_rooms from .utils import get_current_or_next_week, get_week, group_courses -ICAL_NAMES = ["uid", "summary", "description", "location", "start", "dtstart", "dtend"] +ICAL_NAMES = ["uid", "summary", "description", "location", "start", "dtstart", "dtend", "dtstamp"] class IcalFeedGenerator(SyndicationFeed): @@ -69,12 +70,13 @@ class IcalFeed(Feed): return "" def items(self, obj): - return Course.objects.get_courses_for_group(obj).order_by("begin") + return Course.objects.get_courses_for_group(obj).annotate(year=ExtractYear("begin"), week=ExtractWeek("begin")) def item_extra_kwargs(self, item): return {"uid": "{0}@celcatsanitizer".format(item.id), "dtstart": item.begin, "dtend": item.end, + "dtstamp": LastUpdate.objects.get(timetable=item.timetable, year=item.year, week=item.week).updated_at, "summary": item.name, "location": format_rooms(item.rooms.all())} -- cgit v1.2.1