mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Bring reddit app up to date with new TZ requirements
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
VERSION = (0, 1)
|
VERSION = (0, 2)
|
||||||
|
|
||||||
# Dynamically calculate the version based on VERSION tuple
|
# Dynamically calculate the version based on VERSION tuple
|
||||||
if len(VERSION)>2 and VERSION[2] is not None:
|
if len(VERSION)>2 and VERSION[2] is not None:
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import urllib
|
|||||||
from django.utils import simplejson as json
|
from django.utils import simplejson as json
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from django.utils.timezone import now, utc
|
||||||
|
|
||||||
from reddit.api import Comment
|
from reddit.api import Comment
|
||||||
|
|
||||||
@@ -49,8 +50,8 @@ class RedditAccount(models.Model):
|
|||||||
self.comment_karma = int(data['comment_karma'])
|
self.comment_karma = int(data['comment_karma'])
|
||||||
self.reddit_id = unicode(data['id'], 'utf-8')
|
self.reddit_id = unicode(data['id'], 'utf-8')
|
||||||
|
|
||||||
self.date_created = datetime.fromtimestamp(data['created_utc'])
|
self.date_created = datetime.fromtimestamp(data['created_utc']).replace(tzinfo=utc)
|
||||||
self.last_update = datetime.now()
|
self.last_update = now()
|
||||||
|
|
||||||
def recent_posts(self):
|
def recent_posts(self):
|
||||||
""" Returns the first page of posts visible on the user's profile page """
|
""" Returns the first page of posts visible on the user's profile page """
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from urllib2 import HTTPError, URLError
|
from urllib2 import HTTPError, URLError
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.utils.timezone import now
|
||||||
|
|
||||||
from celery.task import Task, task
|
from celery.task import Task, task
|
||||||
|
|
||||||
from reddit.models import RedditAccount
|
from reddit.models import RedditAccount
|
||||||
from reddit.api import Inbox, LoginError, Flair
|
from reddit.api import Inbox, LoginError, Flair
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
class send_reddit_message(Task):
|
class send_reddit_message(Task):
|
||||||
|
|
||||||
@@ -71,8 +76,8 @@ def queue_account_updates(update_delay=604800, batch_size=50):
|
|||||||
log = queue_account_updates.get_logger()
|
log = queue_account_updates.get_logger()
|
||||||
# Update all the eve accounts and related corps
|
# Update all the eve accounts and related corps
|
||||||
delta = timedelta(seconds=update_delay)
|
delta = timedelta(seconds=update_delay)
|
||||||
log.info("Updating Accounts older than %s" % (datetime.now() - delta))
|
log.info("Updating Accounts older than %s" % (now() - delta))
|
||||||
accounts = RedditAccount.objects.order_by('last_update').filter(last_update__lt=(datetime.now() - delta))[:batch_size]
|
accounts = RedditAccount.objects.order_by('last_update').filter(last_update__lt=(now() - delta))[:batch_size]
|
||||||
log.info("%s account(s) to update" % accounts.count())
|
log.info("%s account(s) to update" % accounts.count())
|
||||||
for acc in accounts:
|
for acc in accounts:
|
||||||
log.debug("Queueing Account %s for update" % acc.username)
|
log.debug("Queueing Account %s for update" % acc.username)
|
||||||
|
|||||||
Reference in New Issue
Block a user