Permalink
Browse files

show content api

  • Loading branch information...
1 parent 89a9e39 commit d47d5771e3643e3b29378e694fcc0de9a6e45ad1 Lisa van Gelder committed Feb 3, 2012
Showing with 18 additions and 3 deletions.
  1. +17 −0 app/views.py
  2. +1 −3 feeds/management/commands/update_feeds.py
View
@@ -35,4 +35,21 @@ def dashboard(request):
'stories': tweetjson
})
+
+ contentapi_stories = Story.objects.filter(latest=True, source='ContentAPI')[:settings.STORIES_PER_FEED]
+ contentapijson = []
+ for contentapi_story in contentapi_stories:
+ contentapijson.append({
+ 'key': contentapi_story.key,
+ 'title': contentapi_story.title,
+ 'thumbnail': contentapi_story.thumbnail,
+ 'permalink': contentapi_story.permalink
+ },)
+
+ feeds.append({
+ 'title': 'ContentAPI',
+ 'stories': contentapijson
+ })
+
+
return render(request, 'app/dashboard.html', {'feeds': feeds})
@@ -21,7 +21,6 @@ def save_storify_story(self, story):
def check_for_updates(self, story, existing_story):
- print story
if story['stats']['views'] != existing_story.views:
self.save_storify_story(story)
existing_story.latest = False
@@ -87,7 +86,7 @@ def save_tweetminster_story(self, story):
def fetch_from_content_api(self):
"""Connect to the content API, retrieve popular stories, and store."""
- r = requests.get('http://content.guardianapis.com/search?page-size=10&format=json&show-fields=all')
+ r = requests.get('http://content.guardianapis.com/search?page-size=%d&format=json&show-fields=all' % settings.STORIES_PER_FEED)
if r.status_code != 200:
raise CommandError('content API returned a %d status code' % r.status_code)
@@ -104,7 +103,6 @@ def fetch_from_content_api(self):
self.save_content_api_story(story)
def save_content_api_story(self, story):
- print story['sectionId']
try:
thumbnail = story['fields']['thumbnail']
except KeyError:

0 comments on commit d47d577

Please sign in to comment.