mirror of https://github.com/zulip/zulip.git
Make timestamps on zephyrs timezone-aware.
This will avoid Daylight Saving Time issues and resolves a Django warning about using naive datetime objects ("RuntimeWarning: DateTimeField received a naive datetime"). This adds a dependency on python-tz. https://docs.djangoproject.com/en/dev/topics/i18n/timezones/ (imported from commit 10e432a67e2bcd014a0cedf4423a162609873825)
This commit is contained in:
parent
7b40df9e8b
commit
36cc0219d5
|
@ -2,7 +2,7 @@
|
|||
resize2fs /dev/xvda1
|
||||
apt-get update
|
||||
apt-get upgrade
|
||||
apt-get install sudo emacs screen git
|
||||
apt-get install sudo emacs screen git python-tz
|
||||
|
||||
cat >>/etc/apt/sources.list <<EOF
|
||||
deb http://backports.debian.org/debian-backports squeeze-backports main
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from django.core.management.base import NoArgsCommand
|
||||
from django.utils.timezone import utc
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from zephyr.models import Zephyr, UserProfile, ZephyrClass, Recipient
|
||||
|
@ -47,7 +48,7 @@ class Command(NoArgsCommand):
|
|||
new_zephyr.recipient = Recipient.objects.get(id=random.choice(recipients))
|
||||
zephyr_class = ZephyrClass.objects.get(pk=new_zephyr.recipient.pk)
|
||||
new_zephyr.instance = zephyr_class.name + str(random.randint(1, 3))
|
||||
new_zephyr.pub_date = datetime.datetime.utcnow()
|
||||
new_zephyr.pub_date = datetime.datetime.utcnow().replace(tzinfo=utc)
|
||||
new_zephyr.save()
|
||||
|
||||
self.stdout.write("Successfully populated test database.\n")
|
||||
|
|
|
@ -111,7 +111,7 @@ def personal_zephyr(request):
|
|||
new_zephyr.content = request.POST['new_personal_zephyr']
|
||||
new_zephyr.recipient = recipient
|
||||
new_zephyr.instance = u''
|
||||
new_zephyr.pub_date = datetime.datetime.utcnow()
|
||||
new_zephyr.pub_date = datetime.datetime.utcnow().replace(tzinfo=utc)
|
||||
new_zephyr.save()
|
||||
|
||||
return HttpResponseRedirect(reverse('zephyr.views.home'))
|
||||
|
@ -136,7 +136,7 @@ def zephyr(request):
|
|||
new_zephyr.content = request.POST['new_zephyr']
|
||||
new_zephyr.recipient = recipient
|
||||
new_zephyr.instance = request.POST['instance']
|
||||
new_zephyr.pub_date = datetime.datetime.utcnow()
|
||||
new_zephyr.pub_date = datetime.datetime.utcnow().replace(tzinfo=utc)
|
||||
new_zephyr.save()
|
||||
|
||||
return HttpResponseRedirect(reverse('zephyr.views.home'))
|
||||
|
|
Loading…
Reference in New Issue