diff options
author | Alban Gruin | 2017-09-24 15:01:59 +0200 |
---|---|---|
committer | Alban Gruin | 2017-09-24 15:04:23 +0200 |
commit | 0949b09c0040a66ffd1869da23a9425da891d56f (patch) | |
tree | 63ea62c34383e526a927f21d0c82983f7cd65fa9 /feeds.py | |
parent | 6f026e4f0bca3cc3bb137bc26967283510c135de (diff) |
Ajout du champ dtstamp aux fichiers iCalendar.v0.9.2stable/0.9.z
Suppression du order_by("begin") redondant lors de la récupération des cours
Diffstat (limited to 'feeds.py')
-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())} |