Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #36 from brutasse/aggregator-improvements

Aggregator improvements
  • Loading branch information...
commit acba0a4dd770a82bbdb3d189d79d6c43512584e5 2 parents 7f4161b + 832e273
Jannis Leidel jezdez authored
Showing with 14 additions and 7 deletions.
  1. +1 −1  deploy-requirements.txt
  2. +13 −6 django_website/aggregator/models.py
2  deploy-requirements.txt
View
@@ -7,7 +7,7 @@ django-push == 0.4
django-registration == 0.7
django-secure == 0.1.0
docutils >= 0.6, < 0.7
-FeedParser >= 5.0, <= 5.1
+feedparser==5.1.1
Jinja2 >= 2.4, < 2.5
psycopg2 >= 2.2, < 2.3
python-memcached >= 1.45, < 2.0
19 django_website/aggregator/models.py
View
@@ -124,16 +124,23 @@ def feed_updated(sender, notification, **kwargs):
log.error("Feed ID %s has an entry ('%s') without a link or guid. Skipping.", feed.id, title)
link = getattr(entry, "link", guid)
+ content = u''
if hasattr(entry, "summary"):
content = entry.summary
- elif hasattr(entry, "content"):
- content = entry.content[0].value
- elif hasattr(entry, "description"):
+
+ if hasattr(entry, "description"):
content = entry.description
- else:
- content = u""
- if entry.has_key('updated_parsed'):
+ # 'content' takes precedence on anything else. 'summary' and
+ # 'description' are usually truncated so it's safe to overwrite them
+ if hasattr(entry, "content"):
+ content = u''
+ for item in entry.content:
+ content += item.value
+
+ if 'published_parsed' in entry and entry.published_parsed is not None:
+ date_modified = datetime.datetime(*entry.published_parsed[:6])
+ elif 'updated_parsed' in entry and entry.updated_parsed is not None:
date_modified = datetime.datetime(*entry.updated_parsed[:6])
else:
date_modified = datetime.datetime.now()
Please sign in to comment.
Something went wrong with that request. Please try again.