From 30b48eb41a9515feaf7dbc5cd4eb8847371b237c Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Mon, 6 Jul 2015 21:21:52 +0200 Subject: adding feed icons on feed pages --- pyaggr3g470r/lib/article_utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'pyaggr3g470r/lib') diff --git a/pyaggr3g470r/lib/article_utils.py b/pyaggr3g470r/lib/article_utils.py index 3c642167..79ac34f5 100644 --- a/pyaggr3g470r/lib/article_utils.py +++ b/pyaggr3g470r/lib/article_utils.py @@ -35,6 +35,8 @@ def extract_id(entry, keys=[('link', 'link'), def construct_article(entry, feed): + if hasattr(feed, 'dump'): # this way can be a sqlalchemy obj or a dict + feed = feed.dump() "Safe method to transorm a feedparser entry into an article" now = datetime.now() @@ -63,10 +65,10 @@ def construct_article(entry, feed): logger.warning("Unable to get the real URL of %s. Error: %s", article_link, error) - return {'feed_id': feed.id, - 'user_id': feed.user_id, + return {'feed_id': feed['id'], + 'user_id': feed['user_id'], 'entry_id': extract_id(entry).get('entry_id', None), - 'link': entry.get('link', feed.site_link), + 'link': entry.get('link', feed['site_link']), 'title': entry.get('title', 'No title'), 'readed': False, 'like': False, 'content': content, -- cgit From c2f8aad7e3b849ebad7f5487b106bdd83256d140 Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Mon, 6 Jul 2015 21:49:50 +0200 Subject: important fix, the retrieved_date was always now, leading to unmatchable article (added again and again) --- pyaggr3g470r/lib/article_utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'pyaggr3g470r/lib') diff --git a/pyaggr3g470r/lib/article_utils.py b/pyaggr3g470r/lib/article_utils.py index 79ac34f5..115b6058 100644 --- a/pyaggr3g470r/lib/article_utils.py +++ b/pyaggr3g470r/lib/article_utils.py @@ -38,7 +38,7 @@ def construct_article(entry, feed): if hasattr(feed, 'dump'): # this way can be a sqlalchemy obj or a dict feed = feed.dump() "Safe method to transorm a feedparser entry into an article" - now = datetime.now() + date = datetime.now() for date_key in ('published', 'updated'): if entry.get(date_key): @@ -72,5 +72,5 @@ def construct_article(entry, feed): 'title': entry.get('title', 'No title'), 'readed': False, 'like': False, 'content': content, - 'retrieved_date': now.isoformat(), - 'date': (date or now).isoformat()} + 'retrieved_date': date.isoformat(), + 'date': date.isoformat()} -- cgit From 8bbfd0e080ac5ef1232cca0663f77e1562c1485e Mon Sep 17 00:00:00 2001 From: François Schmidts Date: Mon, 6 Jul 2015 23:09:24 +0200 Subject: making it possible for super admin to update other's feed --- pyaggr3g470r/lib/crawler.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pyaggr3g470r/lib') diff --git a/pyaggr3g470r/lib/crawler.py b/pyaggr3g470r/lib/crawler.py index 8d2de15f..de557e45 100644 --- a/pyaggr3g470r/lib/crawler.py +++ b/pyaggr3g470r/lib/crawler.py @@ -143,6 +143,7 @@ class PyAggUpdater(AbstractCrawler): up_feed[key] = fresh_feed[key] if not self.feed.get('title'): up_feed['title'] = fresh_feed.get('title', '') + up_feed['user_id'] = self.feed['user_id'] logger.info('%r %r - pushing feed attrs %r', self.feed['id'], self.feed['title'], -- cgit