pull/64/head
JamesRamm 2017-04-10 17:32:45 +01:00
rodzic a34fcbb7a3
commit ebeff468f1
4 zmienionych plików z 18 dodań i 3 usunięć

Wyświetl plik

@ -1,6 +1,9 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from longclaw.settings import PRODUCT_VARIANT_MODEL
@python_2_unicode_compatible
class BasketItem(models.Model):
basket_id = models.CharField(max_length=32)
date_added = models.DateTimeField(auto_now_add=True)

Wyświetl plik

@ -1,7 +1,10 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from longclaw.settings import PRODUCT_VARIANT_MODEL
from longclaw.longclawshipping.models import Address
@python_2_unicode_compatible
class Order(models.Model):
SUBMITTED = 1
FULFILLED = 2
@ -31,6 +34,9 @@ class Order(models.Model):
blank=True,
null=True)
def __str__(self):
return "Order #{} - {}".format(self.id, self.email)
@property
def total(self):
total = 0
@ -42,7 +48,7 @@ class Order(models.Model):
def total_items(self):
return self.items.count()
@python_2_unicode_compatible
class OrderItem(models.Model):
product = models.ForeignKey(PRODUCT_VARIANT_MODEL, on_delete=models.DO_NOTHING)
quantity = models.IntegerField(default=1)

Wyświetl plik

@ -1,4 +1,5 @@
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django_extensions.db.fields import AutoSlugField
from modelcluster.fields import ParentalKey
@ -55,6 +56,7 @@ class Product(Page):
'''
return any(self.variants.filter(stock__gt=0))
@python_2_unicode_compatible
class ProductVariantBase(models.Model):
"""
Base model for creating product variants
@ -70,6 +72,9 @@ class ProductVariantBase(models.Model):
class Meta:
abstract = True
def __str__(self):
return "{} - {}".format(self.product.title, self.ref)
def get_product_title(self):
return self.product.title

Wyświetl plik

@ -1,9 +1,9 @@
from django.db import models
from django import forms
from django.utils.encoding import python_2_unicode_compatible
from wagtail.wagtailadmin.edit_handlers import FieldPanel
from django_countries.fields import CountryField
from wagtail.wagtailsnippets.models import register_snippet
from django_countries.fields import CountryField
@register_snippet
@python_2_unicode_compatible
@ -27,6 +27,7 @@ class Address(models.Model):
def __str__(self):
return "{}, {}, {}".format(self.name, self.city, self.country)
@python_2_unicode_compatible
class ShippingRate(models.Model):
'''
An individual shipping rate. This can be applied to