From 7687acb366afe913df40aab0f6dbfb30cdb67304 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 11 Sep 2020 19:15:39 +0200 Subject: [PATCH 1/6] Changed scope (?) of remaining local imports. --- lostplaces/lostplaces/settings.py | 2 +- lostplaces/lostplaces_app/admin.py | 4 ++-- lostplaces/lostplaces_app/urls.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lostplaces/lostplaces/settings.py b/lostplaces/lostplaces/settings.py index f02ff25..127b8c1 100644 --- a/lostplaces/lostplaces/settings.py +++ b/lostplaces/lostplaces/settings.py @@ -143,6 +143,6 @@ LOGOUT_REDIRECT_URL = reverse_lazy('lostplaces_home') # Load and override settings from local_settings.py and don't fail on errors. try: - from .local_settings import * + from lostplaces_app.local_settings import * except ImportError: pass diff --git a/lostplaces/lostplaces_app/admin.py b/lostplaces/lostplaces_app/admin.py index 5d53ab7..d2945df 100644 --- a/lostplaces/lostplaces_app/admin.py +++ b/lostplaces/lostplaces_app/admin.py @@ -6,9 +6,9 @@ from django.contrib import admin from django.contrib.auth import get_user_model from django.contrib.auth.admin import UserAdmin -from .models import * +from lostplaces_app.models import * -from .forms import ExplorerCreationForm, ExplorerChangeForm +from lostplaces_app.forms import ExplorerCreationForm, ExplorerChangeForm # Register your models here. diff --git a/lostplaces/lostplaces_app/urls.py b/lostplaces/lostplaces_app/urls.py index fabf191..2e7262d 100644 --- a/lostplaces/lostplaces_app/urls.py +++ b/lostplaces/lostplaces_app/urls.py @@ -1,5 +1,5 @@ from django.urls import path -from .views import ( +from lostplaces_app.views import ( HomeView, PlaceDetailView, PlaceListView, From f5bf642cd69ffea494fbe9fb9b92aa401272de1c Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 11 Sep 2020 19:23:13 +0200 Subject: [PATCH 2/6] Ups, not for the settings file. --- lostplaces/lostplaces/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lostplaces/lostplaces/settings.py b/lostplaces/lostplaces/settings.py index 127b8c1..f02ff25 100644 --- a/lostplaces/lostplaces/settings.py +++ b/lostplaces/lostplaces/settings.py @@ -143,6 +143,6 @@ LOGOUT_REDIRECT_URL = reverse_lazy('lostplaces_home') # Load and override settings from local_settings.py and don't fail on errors. try: - from lostplaces_app.local_settings import * + from .local_settings import * except ImportError: pass From f49581259e71054358420f37f85ddf690c83a365 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 11 Sep 2020 19:32:07 +0200 Subject: [PATCH 3/6] Typo in class name. --- lostplaces/lostplaces_app/tests/models/test_voucher_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lostplaces/lostplaces_app/tests/models/test_voucher_model.py b/lostplaces/lostplaces_app/tests/models/test_voucher_model.py index 89c733e..c2cb5be 100644 --- a/lostplaces/lostplaces_app/tests/models/test_voucher_model.py +++ b/lostplaces/lostplaces_app/tests/models/test_voucher_model.py @@ -14,7 +14,7 @@ def mock_voucher(): ) -class VoucheTestCase(ModelTestCase, TestCase): +class VoucherTestCase(ModelTestCase, TestCase): model_name = 'Voucher' def setUp(self): @@ -48,4 +48,4 @@ class VoucheTestCase(ModelTestCase, TestCase): msg='Expecting %s.__str__ to contain the voucher code' % ( self.model_name ) - ) \ No newline at end of file + ) From c78858c15229f07a5387ae370e0a484ac2bff6e3 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 11 Sep 2020 22:03:20 +0200 Subject: [PATCH 4/6] Changed class attibutes to match test expectation. --- lostplaces/lostplaces_app/admin.py | 4 ++-- lostplaces/lostplaces_app/models.py | 6 +++--- .../lostplaces_app/tests/models/test_voucher_model.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lostplaces/lostplaces_app/admin.py b/lostplaces/lostplaces_app/admin.py index d2945df..dc52e86 100644 --- a/lostplaces/lostplaces_app/admin.py +++ b/lostplaces/lostplaces_app/admin.py @@ -13,8 +13,8 @@ from lostplaces_app.forms import ExplorerCreationForm, ExplorerChangeForm # Register your models here. class VoucherAdmin(admin.ModelAdmin): - fields = ['code', 'expires', 'created'] - readonly_fields = ['created'] + fields = ['code', 'expires_when', 'created_when'] + readonly_fields = ['created_when'] admin.site.register(Explorer) admin.site.register(Voucher, VoucherAdmin) diff --git a/lostplaces/lostplaces_app/models.py b/lostplaces/lostplaces_app/models.py index 8e1885a..4df6736 100644 --- a/lostplaces/lostplaces_app/models.py +++ b/lostplaces/lostplaces_app/models.py @@ -54,11 +54,11 @@ class Voucher(models.Model): """ code = models.CharField(unique=True, max_length=30) - created = models.DateTimeField(auto_now_add=True) - expires = models.DateField() + created_when = models.DateTimeField(auto_now_add=True) + expires_when = models.DateTimeField() def __str__(self): - return "Voucher " + str(self.pk) + return "Voucher " + str(self.code) class Place (models.Model): diff --git a/lostplaces/lostplaces_app/tests/models/test_voucher_model.py b/lostplaces/lostplaces_app/tests/models/test_voucher_model.py index c2cb5be..5ab7b4b 100644 --- a/lostplaces/lostplaces_app/tests/models/test_voucher_model.py +++ b/lostplaces/lostplaces_app/tests/models/test_voucher_model.py @@ -10,7 +10,7 @@ from lostplaces_app.tests.models import ModelTestCase def mock_voucher(): return Voucher.objects.create( code='ayDraJCCwfhcFiYmSR5GrcjcchDfcahv', - expires=datetime.datetime.now() + datetime.timedelta(days=1) + expires_when=datetime.datetime.now() + datetime.timedelta(days=1) ) From aed2856df34bab49e99680f2f5f113c1d828b294 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 11 Sep 2020 22:22:03 +0200 Subject: [PATCH 5/6] Made the test timezone aware, DateTimeFiled(auto_now_add) already was. --- lostplaces/lostplaces_app/tests/models/test_voucher_model.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lostplaces/lostplaces_app/tests/models/test_voucher_model.py b/lostplaces/lostplaces_app/tests/models/test_voucher_model.py index 5ab7b4b..608f38b 100644 --- a/lostplaces/lostplaces_app/tests/models/test_voucher_model.py +++ b/lostplaces/lostplaces_app/tests/models/test_voucher_model.py @@ -2,6 +2,7 @@ import datetime from django.test import TestCase from django.db import models +from django.utils import timezone from lostplaces_app.models import Voucher from lostplaces_app.tests.models import ModelTestCase @@ -10,7 +11,7 @@ from lostplaces_app.tests.models import ModelTestCase def mock_voucher(): return Voucher.objects.create( code='ayDraJCCwfhcFiYmSR5GrcjcchDfcahv', - expires_when=datetime.datetime.now() + datetime.timedelta(days=1) + expires_when=timezone.now() + datetime.timedelta(days=1) ) From d993387216a37920e4f0f8366836100c61a247f7 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 11 Sep 2020 22:43:03 +0200 Subject: [PATCH 6/6] Fixed text repr of Explorer model due to user model change. --- lostplaces/lostplaces_app/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lostplaces/lostplaces_app/models.py b/lostplaces/lostplaces_app/models.py index 4df6736..b40462b 100644 --- a/lostplaces/lostplaces_app/models.py +++ b/lostplaces/lostplaces_app/models.py @@ -33,7 +33,7 @@ class Explorer(models.Model): ) def __str__(self): - return self.user.name + return self.user.username @receiver(post_save, sender=User) def create_user_profile(sender, instance, created, **kwargs):