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