Mercurial > public > sg101
diff forums/latest.py @ 1171:c855a88f9d78
Merge mainline into V3 dev branch
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 07 Jan 2018 12:00:24 -0600 |
parents | 90e8cc6eff77 |
children | e9f6a2c5c1de |
line wrap: on
line diff
--- a/forums/latest.py Sun Aug 27 17:05:08 2017 -0500 +++ b/forums/latest.py Sun Jan 07 12:00:24 2018 -0600 @@ -55,8 +55,10 @@ import logging import time +from django.conf import settings from django.dispatch import receiver from django.template.loader import render_to_string +import pytz import redis from forums.signals import post_content_update, topic_content_update @@ -72,6 +74,8 @@ # This controls how many updated topics we track MAX_UPDATED_TOPICS = 50 +SERVER_TZ = pytz.timezone(settings.TIME_ZONE) + # Redis key names: POST_COUNT_KEY = "forums:public_post_count" TOPIC_COUNT_KEY = "forums:public_topic_count" @@ -292,7 +296,9 @@ post = json.loads(raw_post) # fix up the pubdate; turn it back into a datetime object - post['pubdate'] = datetime.datetime.fromtimestamp(post['pubdate']) + pubdate = datetime.datetime.utcfromtimestamp(post['pubdate']) + pubdate.replace(tzinfo=SERVER_TZ) + post['pubdate'] = pubdate posts.append(post) @@ -474,7 +480,7 @@ 'title': post.topic.name, 'content': content, 'author': post.user.username, - 'pubdate': int(time.mktime(post.creation_date.timetuple())), + 'pubdate': int(time.mktime(post.creation_date.utctimetuple())), 'forum_name': post.topic.forum.name, 'url': post.get_absolute_url() }