public
Description: stuff for my site
Homepage: http://www.thescoop.org/docs
Clone URL: git://github.com/dwillis/thescoop.git
Derek Willis (author)
Thu Jul 10 17:32:57 -0700 2008
thescoop / feeds.py
100644 85 lines (61 sloc) 2.463 kb
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
from django.contrib.syndication.feeds import Feed
from thescoop.car.models import Byline, Datatype, Nation, Source, State, Story, Topic, Type, Database, Application
 
class LatestEntries(Feed):
  title = "The Scoop DOCS Recent Stories Feed"
  link = "/docs/"
  description = "Most recent stories posted to DOCS"
 
  def items(self):
    return Story.objects.select_related().order_by('-postdate')[:10]
 
class LatestDatabases(Feed):
  title = "The Scoop Recent Databases Feed"
  link = "/dbs/"
  description = "Most recent databases posted"
 
  def items(self):
   return Database.objects.select_related().all().order_by('-post_date')[:10]
 
class LatestBylines(Feed):
  title = "The Scoop DOCS Recent Bylines Feed"
  link = "/docs/"
  description = "Most recent bylines posted to DOCS"
 
  def items(self):
    return Byline.objects.order_by('-id')[:15]
 
class LatestSources(Feed):
  title = "The Scoop DOCS Recent Sources Feed"
  link = "/docs/"
  description = "Most recent sources posted to DOCS"
 
  def items(self):
    return Source.objects.order_by('-id')[:10]
 
class TopicFeed(Feed):
  def get_object(self, bits):
#    if len(bits) != 1:
#      raise ObjectDoesNotExist
    return Topic.objects.get(topicslug__exact=bits[0])
 
  def title(self, obj):
    return "The Scoop DOCS: Stories on %s" % obj.topicname
 
  def link(self, obj):
    return obj.get_absolute_url()
 
  def description(self, obj):
    return "Stories recently added on %s" % obj.topicname
 
  def items(self, obj):
    return Story.objects.select_related().filter(topic__topicslug__exact=obj.topicslug).order_by('-pubdate')[:15]
 
class SourceFeed(Feed):
  def get_object(self, bits):
    return Source.objects.get(sourceslug__exact=bits[0])
 
  def title(self, obj):
    return "The Scoop DOCS: Stories from %s" % obj.name
 
  def link(self, obj):
    return obj.get_absolute_url()
 
  def description(self, obj):
    return "Stories recently added on %s" % obj.name
 
  def items(self, obj):
    return Story.objects.select_related().filter(source__sourceslug__exact=obj.sourceslug).order_by('-pubdate')[:15]
 
class BylineFeed(Feed):
  def get_object(self, bits):
    return Byline.objects.get(nameslug__exact=bits[0])
 
  def title(self, obj):
    return "The Scoop DOCS: Stories by %s" % obj
 
  def link(self, obj):
    return obj.get_absolute_url()
 
  def description(self, obj):
    return "Recently added stories by %s" % obj
 
  def items(self, obj):
    return Story.objects.select_related().filter(byline__nameslug__exact=obj.nameslug).order_by('-pubdate')[:15]