Compare commits
3 Commits
f5bf642cd6
...
aed2856df3
Author | SHA1 | Date | |
---|---|---|---|
aed2856df3 | |||
c78858c152 | |||
f49581259e |
@ -13,8 +13,8 @@ from lostplaces_app.forms import ExplorerCreationForm, ExplorerChangeForm
|
|||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
||||||
class VoucherAdmin(admin.ModelAdmin):
|
class VoucherAdmin(admin.ModelAdmin):
|
||||||
fields = ['code', 'expires', 'created']
|
fields = ['code', 'expires_when', 'created_when']
|
||||||
readonly_fields = ['created']
|
readonly_fields = ['created_when']
|
||||||
|
|
||||||
admin.site.register(Explorer)
|
admin.site.register(Explorer)
|
||||||
admin.site.register(Voucher, VoucherAdmin)
|
admin.site.register(Voucher, VoucherAdmin)
|
||||||
|
@ -54,11 +54,11 @@ class Voucher(models.Model):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
code = models.CharField(unique=True, max_length=30)
|
code = models.CharField(unique=True, max_length=30)
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created_when = models.DateTimeField(auto_now_add=True)
|
||||||
expires = models.DateField()
|
expires_when = models.DateTimeField()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Voucher " + str(self.pk)
|
return "Voucher " + str(self.code)
|
||||||
|
|
||||||
|
|
||||||
class Place (models.Model):
|
class Place (models.Model):
|
||||||
|
@ -2,6 +2,7 @@ import datetime
|
|||||||
|
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from lostplaces_app.models import Voucher
|
from lostplaces_app.models import Voucher
|
||||||
from lostplaces_app.tests.models import ModelTestCase
|
from lostplaces_app.tests.models import ModelTestCase
|
||||||
@ -10,11 +11,11 @@ from lostplaces_app.tests.models import ModelTestCase
|
|||||||
def mock_voucher():
|
def mock_voucher():
|
||||||
return Voucher.objects.create(
|
return Voucher.objects.create(
|
||||||
code='ayDraJCCwfhcFiYmSR5GrcjcchDfcahv',
|
code='ayDraJCCwfhcFiYmSR5GrcjcchDfcahv',
|
||||||
expires=datetime.datetime.now() + datetime.timedelta(days=1)
|
expires_when=timezone.now() + datetime.timedelta(days=1)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class VoucheTestCase(ModelTestCase, TestCase):
|
class VoucherTestCase(ModelTestCase, TestCase):
|
||||||
model_name = 'Voucher'
|
model_name = 'Voucher'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -48,4 +49,4 @@ class VoucheTestCase(ModelTestCase, TestCase):
|
|||||||
msg='Expecting %s.__str__ to contain the voucher code' % (
|
msg='Expecting %s.__str__ to contain the voucher code' % (
|
||||||
self.model_name
|
self.model_name
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user