Switched to timezone-aware now() function.

This commit is contained in:
Marcus Scholz 2020-09-18 22:04:19 +02:00
parent ce91a19068
commit 618a152f23
5 changed files with 13 additions and 7 deletions

View File

@ -6,6 +6,7 @@
from django.contrib import admin from django.contrib import admin
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.contrib.auth.admin import UserAdmin from django.contrib.auth.admin import UserAdmin
from django.utils import timezone
from lostplaces.models import * from lostplaces.models import *
from lostplaces.forms import ExplorerCreationForm, ExplorerChangeForm from lostplaces.forms import ExplorerCreationForm, ExplorerChangeForm

View File

@ -8,6 +8,7 @@ from django.db import models
from django.core.files import File from django.core.files import File
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils import timezone
from lostplaces.models import PlaceImage, Place from lostplaces.models import PlaceImage, Place
from lostplaces.tests.models import ModelTestCase from lostplaces.tests.models import ModelTestCase
@ -26,7 +27,7 @@ class PlaceImageTestCase(ModelTestCase):
place = Place.objects.create( place = Place.objects.create(
name='Im a place', name='Im a place',
submitted_when=datetime.datetime.now(), submitted_when=timezone.now(),
submitted_by=User.objects.get(username='testpeter').explorer, submitted_by=User.objects.get(username='testpeter').explorer,
location='Testtown', location='Testtown',
latitude=50.5, latitude=50.5,
@ -55,7 +56,7 @@ class PlaceImageTestCase(ModelTestCase):
description='Im a description', description='Im a description',
filename=os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg'), filename=os.path.join(settings.MEDIA_ROOT, 'im_a_image_copy.jpeg'),
place=place, place=place,
submitted_when=datetime.datetime.now(), submitted_when=timezone.now(),
submitted_by=user.explorer submitted_by=user.explorer
) )

View File

@ -4,6 +4,7 @@ from django.test import TestCase
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 import timezone
from lostplaces.models import Place from lostplaces.models import Place
from lostplaces.tests.models import ModelTestCase from lostplaces.tests.models import ModelTestCase
@ -22,7 +23,7 @@ class PlaceTestCase(ModelTestCase):
place = Place.objects.create( place = Place.objects.create(
name='Im a place', name='Im a place',
submitted_when=datetime.datetime.now(), submitted_when=timezone.now(),
submitted_by=user.explorer, submitted_by=user.explorer,
location='Testtown', location='Testtown',
latitude=50.5, latitude=50.5,

View File

@ -4,6 +4,7 @@ from django.test import TestCase, RequestFactory, Client
from django.urls import reverse_lazy from django.urls import reverse_lazy
from django.contrib.auth.models import User, AnonymousUser from django.contrib.auth.models import User, AnonymousUser
from django.contrib.messages.storage.fallback import FallbackStorage from django.contrib.messages.storage.fallback import FallbackStorage
from django.utils import timezone
from lostplaces.models import Place from lostplaces.models import Place
from lostplaces.views import IsAuthenticatedMixin from lostplaces.views import IsAuthenticatedMixin
@ -54,7 +55,7 @@ class TestIsPlaceSubmitterMixin(TestCase):
place = Place.objects.create( place = Place.objects.create(
name='Im a place', name='Im a place',
submitted_when=datetime.datetime.now(), submitted_when=timezone.now(),
submitted_by=user.explorer, submitted_by=user.explorer,
location='Testtown', location='Testtown',
latitude=50.5, latitude=50.5,

View File

@ -3,6 +3,8 @@ import datetime
from django.test import TestCase, Client from django.test import TestCase, Client
from django.urls import reverse from django.urls import reverse
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils import timezone
from lostplaces.models import Place from lostplaces.models import Place
from lostplaces.views import ( from lostplaces.views import (
@ -30,7 +32,7 @@ class TestPlaceCreateView(ViewTestCase):
place = Place.objects.create( place = Place.objects.create(
name='Im a place', name='Im a place',
submitted_when=datetime.datetime.now(), submitted_when=timezone.now(),
submitted_by=user.explorer, submitted_by=user.explorer,
location='Testtown', location='Testtown',
latitude=50.5, latitude=50.5,
@ -63,7 +65,7 @@ class TestPlaceListView(ViewTestCase):
place = Place.objects.create( place = Place.objects.create(
name='Im a place', name='Im a place',
submitted_when=datetime.datetime.now(), submitted_when=timezone.now(),
submitted_by=user.explorer, submitted_by=user.explorer,
location='Testtown', location='Testtown',
latitude=50.5, latitude=50.5,
@ -95,7 +97,7 @@ class PlaceDetailViewTestCase(TaggableViewTestCaseMixin, MapableViewTestCaseMixi
place = Place.objects.create( place = Place.objects.create(
name='Im a place', name='Im a place',
submitted_when=datetime.datetime.now(), submitted_when=timezone.now(),
submitted_by=user.explorer, submitted_by=user.explorer,
location='Testtown', location='Testtown',
latitude=50.5, latitude=50.5,