diff options
author | Alban Gruin | 2017-09-09 11:26:41 +0200 |
---|---|---|
committer | Alban Gruin | 2017-09-09 11:26:41 +0200 |
commit | 0ae8406761f07b9e17229e6723ceb8223d227a8e (patch) | |
tree | bccd9fd578014a4c11f12fa699d50fb7ccdb6ff4 /feeds.py | |
parent | eb050fb7d00351bcac8048f75abd703e68783831 (diff) |
On ne charge la template qu’une fois, ça accélère peut-être le rendu ?
Diffstat (limited to 'feeds.py')
-rw-r--r-- | feeds.py | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -102,16 +102,18 @@ class AtomFeed(Feed): return reverse("timetable", kwargs={"year_slug": group.timetable.year.slug, "timetable_slug": group.timetable.slug, "group_slug": group.slug, "year": item.year, "week": item.week}) def item_description(self, item): - template = loader.get_template("timetable.html") - context = {"group": item.group, "courses": item.courses, "last_update": item, "year": item.year, "week": item.week} - return template.render(context) + return item.description def items(self, obj): + template = loader.get_template("timetable.html") + group = obj[0] + for update in obj[1]: start, end = get_week(update.year, update.week) - courses = Course.objects.get_courses_for_group(obj[0], begin__gte=start, begin__lt=end) + courses = Course.objects.get_courses_for_group(group, begin__gte=start, begin__lt=end) + context = {"group": group, "courses": group_courses(courses), "last_update": update, "year": update.year, "week": update.week} - update.group = obj[0] - update.courses = group_courses(courses) + update.group = group + update.description = template.render(context) return obj[1] |