Commits

Anonymous committed ea7b4e8

Added a a realdate property. Will go back and turn date into time_created.

Comments (0)

Files changed (2)

lifestream/feeds.py

     import traceback,sys
     tb = ''.join(traceback.format_exception(sys.exc_info()[0],
                     sys.exc_info()[1], sys.exc_info()[2]))
-    logger.exception(msg + "\n" + tb) 
+    logger.exception(msg + "\n" + tb)
 
 # MonkeyPatch feedparser so we can get access to interesting parts of media
 # extentions.
     feeds = Feed.objects.fetchable()
     for feed in feeds:
         try:
-            raise Exception("Test error")
             feed_items = parse_feed(feed.url)
-            
+
             # Get the required plugin
             if feed.plugin_class_name:
                 plugin_mod, plugin_class = get_mod_class(feed.plugin_class_name)
                     feed_plugin = plugins.FeedPlugin(feed)
             else:
                 feed_plugin = plugins.FeedPlugin(feed)
-            
+
             included_entries = []
             for entry in feed_items['entries']:
                 try:
                     feed_plugin.pre_process(entry)
-                    
+
                     if feed_plugin.include_entry(entry):
                       included_entries.append(entry)
                 except:
                     log_exception(u"Error importing item from feed '%s'" % feed.url)
-                    
+
             for entry in included_entries:
                 try:
                     i = feed_plugin.process(entry)
 
-                    feed_plugin.post_process(i) 
+                    feed_plugin.post_process(i)
 
                     i.save()
-                    
+
                     # Get tags
                     if 'tagging' in settings.INSTALLED_APPS:
                         from tagging.models import Tag
                             Tag.objects.add_tag(i, re.sub(r"[ ,]+", "_", tag_name))
                 except:
                     log_exception(u"Error importing item from feed '%s'" % feed.url)
-                 
+
         except:
-            log_exception(u"Error importing feed: %s" % feed)  
+            log_exception(u"Error importing feed: %s" % feed)

lifestream/models.py

     """
     site = models.ForeignKey(Site, verbose_name=_(u"site"), db_index=True)
     user = models.ForeignKey(User, verbose_name=_(u"user"), db_index=True)
-    slug = models.SlugField(_("slug"), help_text=_('Slug for use in urls (Autopopulated from the title).'), db_index=True) 
+    slug = models.SlugField(_("slug"), help_text=_('Slug for use in urls (Autopopulated from the title).'), db_index=True)
     title = models.CharField(_("title"), max_length=255)
 
     def __unicode__(self):
 
 class FeedManager(models.Manager):
     ''' Query only normal feeds. '''
-  
+
     def fetchable(self):
         return self.filter(fetchable=True)
 
     url = models.URLField(_("feed url"), help_text=_("Must be a valid url."), verify_exists=True, max_length=1000)
     domain = models.CharField(_("feed domain"), max_length=255, db_index=True)
     fetchable = models.BooleanField(_("fetchable"), default=True, db_index=True)
-    
+
     # The feed plugin name used to process the incoming feed data.
     plugin_class_name = models.CharField(_("plugin name"), max_length=255, null=True, blank=True, choices=getattr(settings, "PLUGINS", PLUGINS))
-    
+
     objects = FeedManager()
-    
+
     def __unicode__(self):
         return self.name
-    
+
 class ItemManager(models.Manager):
     """Manager for querying Items"""
 
     media_player_url = models.URLField(_("media player url"), max_length=1000, null=True, blank=True)
     media_description = models.TextField(_("media description"), null=True, blank=True)
     media_description_type = models.CharField(_("media description type"), max_length=50, null=True, blank=True)
-  
+
     published = models.BooleanField(_("published"), default=True, db_index=True)
-  
+
     objects = ItemManager()
-    
+
     @model_permalink
     def get_absolute_url(self):
         return ('lifestream_item_page', (), {
-            'lifestream_slug': self.feed.lifestream.slug, 
+            'lifestream_slug': self.feed.lifestream.slug,
             'item_id': str(self.id),
         })
-   
+
     def __unicode__(self):
         return self.title
-      
+
+    @property
+    def realdate(self):
+        return self.date.date()
+
     class Meta:
         ordering=["-date", "feed"]