Permalink
Browse files

added handling parsing posts without likes and reposts, added post.by…

…_group and post.by_user properties
  • Loading branch information...
1 parent 83e2974 commit 21688c4f0aadc7f96a627ba20894d165bfdc795b @ramusus committed Apr 5, 2013
Showing with 10 additions and 0 deletions.
  1. +10 −0 vkontakte_wall/models.py
@@ -256,6 +256,12 @@ def on_group_wall(self):
@property
def on_user_wall(self):
return self.wall_owner_content_type == ContentType.objects.get_for_model(User)
+ @property
+ def by_group(self):
+ return self.author_content_type == ContentType.objects.get_for_model(Group)
+ @property
+ def by_user(self):
+ return self.author_content_type == ContentType.objects.get_for_model(User)
def __unicode__(self):
return '%s: %s' % (unicode(self.wall_owner), self.text)
@@ -336,6 +342,8 @@ def fetch_likes(self, offset=0):
try:
self.likes = int(parser.content_bs.find('a', {'id': 'wk_likes_tablikes'}).find('nobr').text.split()[0])
self.save()
+ except ValueError:
+ return
except:
log.warning('Strange markup of first page likes response: "%s"' % parser.content)
self.like_users.clear()
@@ -390,6 +398,8 @@ def fetch_reposts(self, offset=0):
try:
self.reposts = int(parser.content_bs.find('a', {'id': 'wk_likes_tabshares'}).find('nobr').text.split()[0])
self.save()
+ except ValueError:
+ return
except:
log.warning('Strange markup of first page shares response: "%s"' % parser.content)
self.repost_users.clear()

0 comments on commit 21688c4

Please sign in to comment.