-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathfeeds.py
More file actions
29 lines (22 loc) · 1023 Bytes
/
feeds.py
File metadata and controls
29 lines (22 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from django.contrib.syndication.views import Feed, FeedDoesNotExist
from django.core.exceptions import ObjectDoesNotExist
from django.contrib.sites.models import Site
from college.models import CollegeCoach
class CoachesFeed(Feed):
link = "/coaches/"
def get_object(self, bits):
if bits[0] in ['hires','departures']:
return bits[0]
else:
raise FeedDoesNotExist
def title(self, obj):
return "College Football Reference (http://www.cfbreference.com) Coaching %s" % obj.title()
def description(self, obj):
return "Updates on coaching %s." % obj
def items(self, obj):
if obj == 'hires':
return CollegeCoach.objects.filter(start_date__isnull=False).order_by('-start_date')[:15]
elif obj == 'departures':
return CollegeCoach.objects.filter(end_date__isnull=False).order_by('-end_date')[:15]
def item_link(self, item):
return item.coach.get_absolute_url()