2017-02-19 15:02:01 +00:00
|
|
|
from django.db import models
|
2017-09-17 12:01:12 +00:00
|
|
|
from modelcluster.fields import ParentalKey
|
|
|
|
from wagtail.wagtailcore.models import Page
|
2017-02-19 15:02:01 +00:00
|
|
|
from wagtail.wagtailcore.fields import RichTextField
|
2017-09-17 12:01:12 +00:00
|
|
|
from wagtail.wagtailadmin.edit_handlers import FieldPanel, InlinePanel
|
|
|
|
from longclaw.longclawproducts.models import ProductVariantBase, ProductBase
|
2017-02-19 15:02:01 +00:00
|
|
|
|
2017-09-17 12:01:12 +00:00
|
|
|
class ProductIndex(Page):
|
|
|
|
'''Index page for all products
|
|
|
|
'''
|
|
|
|
subpage_types = ('products.Product', 'products.ProductIndex')
|
|
|
|
|
|
|
|
|
|
|
|
class Product(ProductBase):
|
|
|
|
parent_page_types = ['products.ProductIndex']
|
|
|
|
description = RichTextField()
|
|
|
|
content_panels = ProductBase.content_panels + [
|
|
|
|
FieldPanel('description'),
|
|
|
|
]
|
2017-02-19 15:02:01 +00:00
|
|
|
|
2017-09-17 12:01:12 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def first_image(self):
|
|
|
|
return self.images.first()
|
|
|
|
|
|
|
|
class ProductVariant(ProductVariantBase):
|
|
|
|
'''Basic product variant for testing
|
|
|
|
'''
|
|
|
|
product = ParentalKey(Product, related_name='variants')
|
2017-02-19 15:02:01 +00:00
|
|
|
description = RichTextField()
|