mirror of https://github.com/zulip/zulip.git
Use django.utils.timezone.now consistently
(imported from commit f223d9c1f6c77012db342b8be7aaed964b9f18c6)
This commit is contained in:
parent
bc2e7d77eb
commit
3b8dbbc7d7
|
@ -1,5 +1,5 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from django.utils.timezone import utc
|
||||
from django.utils.timezone import utc, now
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.sites.models import Site
|
||||
|
@ -630,7 +630,7 @@ def send_messages(data):
|
|||
message.subject = stream.name + str(random.randint(1, 3))
|
||||
saved_data = message.subject
|
||||
|
||||
message.pub_date = datetime.datetime.utcnow().replace(tzinfo=utc)
|
||||
message.pub_date = now()
|
||||
do_send_message(message)
|
||||
|
||||
recipients[num_messages] = [message_type, message.recipient.id, saved_data]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase
|
||||
from django.utils.timezone import utc
|
||||
from django.utils.timezone import now
|
||||
from django.db.models import Q
|
||||
|
||||
from zephyr.models import Message, UserProfile, Stream, Recipient, Subscription, \
|
||||
|
@ -9,7 +9,6 @@ from zephyr.views import json_get_updates
|
|||
from zephyr.decorator import TornadoAsyncException
|
||||
from zephyr.lib.initial_password import initial_password
|
||||
|
||||
import datetime
|
||||
import simplejson
|
||||
import subprocess
|
||||
subprocess.check_call("zephyr/tests/generate-fixtures");
|
||||
|
@ -58,7 +57,7 @@ class AuthedTestCase(TestCase):
|
|||
else:
|
||||
recipient = Stream.objects.get(name=recipient_name, realm=sender.realm)
|
||||
recipient = Recipient.objects.get(type_id=recipient.id, type=message_type)
|
||||
pub_date = datetime.datetime.utcnow().replace(tzinfo=utc)
|
||||
pub_date = now()
|
||||
(sending_client, _) = Client.objects.get_or_create(name="test suite")
|
||||
do_send_message(Message(sender=sender, recipient=recipient, subject="test",
|
||||
pub_date=pub_date, sending_client=sending_client))
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.core.urlresolvers import reverse
|
|||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import render_to_response
|
||||
from django.template import RequestContext
|
||||
from django.utils.timezone import utc
|
||||
from django.utils.timezone import utc, now
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.contrib.auth.views import login as django_login_page
|
||||
from zephyr.models import Message, UserProfile, Stream, Subscription, \
|
||||
|
@ -676,7 +676,7 @@ def send_message_backend(request, user_profile, sender, client_name=None):
|
|||
# Forged messages come with a timestamp
|
||||
message.pub_date = datetime.datetime.utcfromtimestamp(float(request.POST['time'])).replace(tzinfo=utc)
|
||||
else:
|
||||
message.pub_date = datetime.datetime.utcnow().replace(tzinfo=utc)
|
||||
message.pub_date = now()
|
||||
message.sending_client = get_client(client_name)
|
||||
do_send_message(message)
|
||||
|
||||
|
|
Loading…
Reference in New Issue