aboutsummaryrefslogtreecommitdiff
path: root/feeds.py
diff options
context:
space:
mode:
Diffstat (limited to 'feeds.py')
-rw-r--r--feeds.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/feeds.py b/feeds.py
index 8191cbb..37d6f8d 100644
--- a/feeds.py
+++ b/feeds.py
@@ -15,12 +15,14 @@
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.syndication.views import Feed
-from django.utils.feedgenerator import SyndicationFeed
+from django.db.models import Q
+from django.utils.feedgenerator import Atom1Feed, SyndicationFeed
from icalendar import Calendar, Event
-from .models import Course, Group, Timetable, Year
+from .models import Course, Group, LastUpdate, Timetable, Year
from .templatetags.rooms import format_rooms
+from .utils import get_current_or_next_week
ICAL_NAMES = ["summary", "description", "location", "start", "dtstart", "dtend"]
@@ -70,3 +72,20 @@ class IcalFeed(Feed):
"dtend": item.end,
"summary": item.name,
"location": format_rooms(item.rooms.all())}
+
+
+class AtomFeed(Feed):
+ feed_type = Atom1Feed
+
+ def get_object(self, request, year_slug, timetable_slug, group_slug):
+ year, week = get_current_or_next_week()
+ try:
+ group = Group.objects.get(timetable__year__slug=year_slug, timetable__slug=timetable_slug, slug=group_slug)
+ updates = LastUpdate.objects.filter(Q(year=year, week__lte=week) | Q(year__lt=year), timetable__year__slug=year_slug, timetable__slug=timetable_slug).order_by("-year", "-week")[:5]
+ except:
+ raise ObjectDoesNotExist
+ else:
+ return group, updates
+
+ def items(self, obj):
+ pass