diff options
-rw-r--r-- | feeds.py | 6 |
1 files changed, 4 insertions, 2 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 = ["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())} |