aboutsummaryrefslogtreecommitdiff
path: root/feeds.py
diff options
context:
space:
mode:
Diffstat (limited to 'feeds.py')
-rw-r--r--feeds.py39
1 files changed, 31 insertions, 8 deletions
diff --git a/feeds.py b/feeds.py
index 19c9e47..ff00066 100644
--- a/feeds.py
+++ b/feeds.py
@@ -28,7 +28,8 @@ from .models import Course, Group
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", "dtstamp"]
+ICAL_NAMES = ["uid", "summary", "description", "location",
+ "start", "dtstart", "dtend", "dtstamp"]
class IcalFeedGenerator(SyndicationFeed):
@@ -57,7 +58,9 @@ class IcalFeed(Feed):
def get_object(self, request, year_slug, timetable_slug, group_slug):
try:
- group = Group.objects.get(timetable__year__slug=year_slug, timetable__slug=timetable_slug, slug=group_slug)
+ group = Group.objects.get(timetable__year__slug=year_slug,
+ timetable__slug=timetable_slug,
+ slug=group_slug)
except:
raise ObjectDoesNotExist
else:
@@ -87,16 +90,28 @@ class RSSFeed(Feed):
begin, end = get_week(year, week)
try:
- group = Group.objects.get(timetable__year__slug=year_slug, timetable__slug=timetable_slug, slug=group_slug)
+ group = Group.objects.get(timetable__year__slug=year_slug,
+ timetable__slug=timetable_slug,
+ slug=group_slug)
except:
raise ObjectDoesNotExist
else:
- updates = Course.objects.get_courses_for_group(group, begin__lt=end).annotate(year=ExtractYear("begin"), week=ExtractWeek("begin")).values("year", "week").annotate(Count("year", distinct=True), Max("last_update")).order_by("-year", "-week")[:5]
+ updates = Course.objects.get_courses_for_group(group,
+ begin__lt=end) \
+ .annotate(year=ExtractYear("begin"),
+ week=ExtractWeek("begin")) \
+ .values("year", "week") \
+ .annotate(Count("year", distinct=True),
+ Max("last_update")) \
+ .order_by("-year", "-week")[:5]
return group, updates
def link(self, obj):
group = obj[0]
- link = reverse("timetable", kwargs={"year_slug": group.timetable.year.slug, "timetable_slug": group.timetable.slug, "group_slug": group.slug})
+ link = reverse("timetable",
+ kwargs={"year_slug": group.timetable.year.slug,
+ "timetable_slug": group.timetable.slug,
+ "group_slug": group.slug})
return link
def title(self, obj):
@@ -115,7 +130,9 @@ class RSSFeed(Feed):
return item["description"]
def item_title(self, item):
- return "{0}, semaine {1} de {2}".format(item["group"], item["week"], item["year"])
+ return "{0}, semaine {1} de {2}".format(item["group"],
+ item["week"],
+ item["year"])
def item_updateddate(self, item):
return item["last_update__max"]
@@ -126,8 +143,14 @@ class RSSFeed(Feed):
for update in obj[1]:
start, end = get_week(update["year"], update["week"])
- courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end)
- context = {"group": group, "courses": group_courses(courses), "last_update": update["last_update__max"], "year": update["year"], "week": update["week"]}
+ courses = Course.objects.get_courses_for_group(group,
+ begin__gte=start,
+ begin__lt=end)
+ context = {"group": group,
+ "courses": group_courses(courses),
+ "last_update": update["last_update__max"],
+ "year": update["year"],
+ "week": update["week"]}
update["group"] = group
update["description"] = template.render(context)