forked from mirrors/bookwyrm
Resolves timezone warnings
This commit is contained in:
parent
ef9e130669
commit
64abdafcba
2 changed files with 5 additions and 3 deletions
|
@ -8,6 +8,7 @@ from django.contrib.contenttypes.models import ContentType
|
||||||
from django.http.response import Http404
|
from django.http.response import Http404
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.test.client import RequestFactory
|
from django.test.client import RequestFactory
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from bookwyrm import forms, models, view_actions as actions
|
from bookwyrm import forms, models, view_actions as actions
|
||||||
from bookwyrm.settings import DOMAIN
|
from bookwyrm.settings import DOMAIN
|
||||||
|
@ -361,7 +362,7 @@ class ViewActions(TestCase):
|
||||||
|
|
||||||
def test_edit_readthrough(self):
|
def test_edit_readthrough(self):
|
||||||
''' adding dates to an ongoing readthrough '''
|
''' adding dates to an ongoing readthrough '''
|
||||||
start = dateutil.parser.parse('2021-01-03')
|
start = timezone.make_aware(dateutil.parser.parse('2021-01-03'))
|
||||||
readthrough = models.ReadThrough.objects.create(
|
readthrough = models.ReadThrough.objects.create(
|
||||||
book=self.book, user=self.local_user, start_date=start)
|
book=self.book, user=self.local_user, start_date=start)
|
||||||
request = self.factory.post(
|
request = self.factory.post(
|
||||||
|
|
|
@ -836,7 +836,7 @@ def update_readthrough(request, book=None, create=True):
|
||||||
start_date = request.POST.get('start_date')
|
start_date = request.POST.get('start_date')
|
||||||
if start_date:
|
if start_date:
|
||||||
try:
|
try:
|
||||||
start_date = dateutil.parser.parse(start_date)
|
start_date = timezone.make_aware(dateutil.parser.parse(start_date))
|
||||||
readthrough.start_date = start_date
|
readthrough.start_date = start_date
|
||||||
except ParserError:
|
except ParserError:
|
||||||
pass
|
pass
|
||||||
|
@ -844,7 +844,8 @@ def update_readthrough(request, book=None, create=True):
|
||||||
finish_date = request.POST.get('finish_date')
|
finish_date = request.POST.get('finish_date')
|
||||||
if finish_date:
|
if finish_date:
|
||||||
try:
|
try:
|
||||||
finish_date = dateutil.parser.parse(finish_date)
|
finish_date = timezone.make_aware(
|
||||||
|
dateutil.parser.parse(finish_date))
|
||||||
readthrough.finish_date = finish_date
|
readthrough.finish_date = finish_date
|
||||||
except ParserError:
|
except ParserError:
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Reference in a new issue