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) )