feed id fix, feed_reader will now store an id and return it in the results

This commit is contained in:
Oliver Marks 2017-01-08 13:33:00 +00:00
parent a3e44d640a
commit be559501e1
4 changed files with 10 additions and 6 deletions

View File

@ -1,6 +1,9 @@
pipeline: pipeline:
backend: backend:
image: maidstonehackspacewebsite_django image: maidstonehackspacewebsite_django
environment:
- POSTGRES_USER=mhackspace
- USE_DOCKER=yes
commands: commands:
- python manage.py test - python manage.py test
@ -37,6 +40,4 @@ services:
mailhog: mailhog:
image: mailhog/mailhog image: mailhog/mailhog
ports:
- "8125:8025"

View File

@ -20,8 +20,8 @@ def import_feeds(feed=False):
articles = [] articles = []
for article in rss_articles: for article in rss_articles:
articles.append(Article( articles.append(Article(
url=article['url'], # @olymk2 why cant I do article.url here? url=article['url'],
feed=Feed.objects.get(pk=1), # fixme: Nice hack :) feed=Feed.objects.get(pk=article['id']),
title=article['title'], title=article['title'],
original_image=article['image'], original_image=article['image'],
description=article['description'], description=article['description'],
@ -72,6 +72,7 @@ def get_active_feeds(feed=False):
if feed.enabled is False: if feed.enabled is False:
continue continue
rss_feeds.append({ rss_feeds.append({
'id': feed.id,
'author': feed.author, 'author': feed.author,
'url': feed.feed_url 'url': feed.feed_url
}) })

View File

@ -16,4 +16,6 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
imported = import_feeds(options['blog_id']) imported = import_feeds(options['blog_id'])
self.stdout.write(self.style.SUCCESS('Successfully imported %s articles' % len(imported))) self.stdout.write(
self.style.SUCCESS(
'Successfully imported %s articles' % len(imported)))

View File

@ -6,4 +6,4 @@ register = template.Library()
@register.inclusion_tag('feeds/list.html') @register.inclusion_tag('feeds/list.html')
def show_feeds(): def show_feeds():
return {'articles': Article.objects.filter(displayed=True).select_related('feed').order_by('-date')} return {'articles': Article.objects.filter(displayed=True)}