Added Last API Update field

This commit is contained in:
2010-03-02 23:01:01 +00:00
parent e7ab428044
commit b04f943bc5
2 changed files with 5 additions and 1 deletions

View File

@@ -19,6 +19,8 @@ class RedditAccount(models.Model):
link_karma = models.IntegerField("Link Karma", blank=True, null=True)
comment_karma = models.IntegerField("Comment Karma", blank=True, null=True)
last_update = models.DateTimeField("Last Update from API", blank=False)
def save(self):
try:
jsondoc = json.load(urllib.urlopen("http://reddit.com/user/%s/about.json" % self.username))
@@ -31,6 +33,8 @@ class RedditAccount(models.Model):
self.comment_karma = data['comment_karma']
self.reddit_id = data['id']
self.date_created = datetime.fromtimestamp(data['created_utc'])
self.last_update = datetime.now()
return models.Model.save(self)