[#2594] Si un fil RSS ne fournit pas la date de publication, utiliser la date du...
authorEric Mc Sween <eric.mcsween@auf.org>
Wed, 21 Mar 2012 14:43:41 +0000 (10:43 -0400)
committerEric Mc Sween <eric.mcsween@auf.org>
Wed, 21 Mar 2012 14:43:41 +0000 (10:43 -0400)
auf_savoirs_en_partage/savoirs/models.py

index c676019..ec22245 100644 (file)
@@ -189,8 +189,9 @@ class SourceActualite(models.Model):
         feed = feedparser.parse(self.url)
         for entry in feed.entries:
             if Actualite.all_objects.filter(url=entry.link).count() == 0:
-                ts = entry.updated_parsed
-                date = datetime.date(ts.tm_year, ts.tm_mon, ts.tm_mday)
+                ts = entry.get('updated_parsed')
+                date = datetime.date(ts.tm_year, ts.tm_mon, ts.tm_mday) \
+                        if ts else datetime.date.today()
                 self.actualites.create(
                     titre=entry.title, texte=entry.summary_detail.value,
                     url=entry.link, date=date