diff options
author | Alban Gruin | 2017-09-24 15:17:33 +0200 |
---|---|---|
committer | Alban Gruin | 2017-09-24 15:17:33 +0200 |
commit | 09d256c882b72cc3d397b4f5e776094a7725fcc1 (patch) | |
tree | 024020eb42a80a46f54ddae1714d11c0f783e648 | |
parent | a2e31953c101d65c842c8673c0f5321f01206037 (diff) | |
parent | 0949b09c0040a66ffd1869da23a9425da891d56f (diff) |
Merge branch 'stable/0.9.z' into prod/pa1ch/0.9.zv0.9.2-pa1chprod/pa1ch/0.9.z
-rw-r--r-- | feeds.py | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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 = ["summary", "description", "location", "start", "dtstart", "dtend"] +ICAL_NAMES = ["uid", "summary", "description", "location", "start", "dtstart", "dtend", "dtstamp"] class IcalFeedGenerator(SyndicationFeed): @@ -35,6 +36,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) @@ -68,11 +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 {"dtstart": item.begin, + 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())} |