Merge branch 'develop' into testing
This commit is contained in:
commit
18a597c726
@ -6,15 +6,15 @@
|
|||||||
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 .models import *
|
from lostplaces_app.models import *
|
||||||
|
|
||||||
from .forms import ExplorerCreationForm, ExplorerChangeForm
|
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)
|
||||||
|
@ -33,7 +33,7 @@ class Explorer(models.Model):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.user.name
|
return self.user.username
|
||||||
|
|
||||||
@receiver(post_save, sender=User)
|
@receiver(post_save, sender=User)
|
||||||
def create_user_profile(sender, instance, created, **kwargs):
|
def create_user_profile(sender, instance, created, **kwargs):
|
||||||
@ -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
|
||||||
@ -14,7 +15,7 @@ class VoucheTestCase(ModelTestCase, TestCase):
|
|||||||
def setUpTestData(cls):
|
def setUpTestData(cls):
|
||||||
Voucher.objects.create(
|
Voucher.objects.create(
|
||||||
code='ayDraJCCwfhcFiYmSR5GrcjcchDfcahv',
|
code='ayDraJCCwfhcFiYmSR5GrcjcchDfcahv',
|
||||||
expires=datetime.datetime.now() + datetime.timedelta(days=1)
|
expires_when=timezone.now() + datetime.timedelta(days=1)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_voucher_code(self):
|
def test_voucher_code(self):
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
from .views import (
|
from lostplaces_app.views import (
|
||||||
HomeView,
|
HomeView,
|
||||||
PlaceDetailView,
|
PlaceDetailView,
|
||||||
PlaceListView,
|
PlaceListView,
|
||||||
|
Loading…
Reference in New Issue
Block a user