kopia lustrzana https://github.com/longclawshop/longclaw
Project template now works, but problems setting custom model
rodzic
78dfe80f2a
commit
230b6e5fc6
|
@ -3,6 +3,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
|
from django.conf import settings
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ class Migration(migrations.Migration):
|
||||||
('basket_id', models.CharField(max_length=32)),
|
('basket_id', models.CharField(max_length=32)),
|
||||||
('date_added', models.DateTimeField(auto_now_add=True)),
|
('date_added', models.DateTimeField(auto_now_add=True)),
|
||||||
('quantity', models.IntegerField(default=1)),
|
('quantity', models.IntegerField(default=1)),
|
||||||
('variant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='longclawproducts.ProductVariant')),
|
('variant', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.PRODUCT_VARIANT_MODEL)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
'ordering': ['date_added'],
|
'ordering': ['date_added'],
|
||||||
|
|
|
@ -4,7 +4,7 @@ from __future__ import unicode_literals
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class Migration(migrations.Migration):
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('quantity', models.IntegerField(default=1)),
|
('quantity', models.IntegerField(default=1)),
|
||||||
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='longclaworders.Order')),
|
('order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='items', to='longclaworders.Order')),
|
||||||
('product', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='longclawproducts.ProductVariant')),
|
('product', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.PRODUCT_VARIANT_MODEL)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.10.4 on 2017-02-19 08:04
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('longclawproducts', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='productvariant',
|
||||||
|
name='product',
|
||||||
|
),
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='ProductVariant',
|
||||||
|
),
|
||||||
|
]
|
|
@ -72,11 +72,6 @@ class ProductVariantBase(models.Model):
|
||||||
def get_product_title(self):
|
def get_product_title(self):
|
||||||
return self.product.title
|
return self.product.title
|
||||||
|
|
||||||
|
|
||||||
class ProductVariant(ProductVariantBase):
|
|
||||||
description = RichTextField()
|
|
||||||
stock = models.IntegerField(default=0)
|
|
||||||
|
|
||||||
class ProductImage(Orderable):
|
class ProductImage(Orderable):
|
||||||
|
|
||||||
product = ParentalKey(Product, related_name='images')
|
product = ParentalKey(Product, related_name='images')
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
from django.db import models
|
||||||
|
from wagtail.wagtailcore.fields import RichTextField
|
||||||
from longclaw.longclawproducts.models import ProductVariantBase
|
from longclaw.longclawproducts.models import ProductVariantBase
|
||||||
|
|
||||||
class ProductVariant(ProductVariantBase):
|
class ProductVariant(ProductVariantBase):
|
||||||
|
@ -6,4 +8,5 @@ class ProductVariant(ProductVariantBase):
|
||||||
# e.g. colour, size, stock and so on.
|
# e.g. colour, size, stock and so on.
|
||||||
# Remember, ProductVariantBase provides 'price', 'ref', 'slug' fields
|
# Remember, ProductVariantBase provides 'price', 'ref', 'slug' fields
|
||||||
# and the parental key to the Product model.
|
# and the parental key to the Product model.
|
||||||
pass
|
description = RichTextField()
|
||||||
|
stock = models.IntegerField(default=0)
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
{% extends "base.html" %}
|
{{% templatetag openblock %} extends "base.html" {% templatetag closeblock %}
|
||||||
|
|
||||||
{% load wagtailcore_tags wagtailimages_tags %}
|
{% templatetag openblock %} load wagtailcore_tags wagtailimages_tags {% templatetag closeblock %}
|
||||||
|
|
||||||
{% block body_class %}template-productpage{% endblock %}
|
{% templatetag openblock %} block body_class {% templatetag closeblock %} template-productpage {% templatetag openblock %}endblock{% templatetag closeblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% templatetag openblock %} block content {% templatetag closeblock %}
|
||||||
<div class="product_content">
|
<div class="product_content">
|
||||||
<div class="image">
|
<div class="image">
|
||||||
{% if page.images %}
|
{% templatetag openblock %} if page.images {% templatetag closeblock %}
|
||||||
{% for item in page.images.all %}
|
{% templatetag openblock %} for item in page.images.all {% templatetag closeblock %}
|
||||||
<div style="float: left; margin: 10px">
|
<div style="float: left; margin: 10px">
|
||||||
{% image item.image fill-320x240 %}
|
{% templatetag openblock %} image item.image fill-320x240 {% templatetag closeblock %}
|
||||||
<p>{{ item.caption }}</p>
|
<p>{% templatetag openvariable %} item.caption {% templatetag closevariable %}</p>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% templatetag openblock %} endfor {% templatetag closeblock %}
|
||||||
{% else %}
|
{% templatetag openblock %} else {% templatetag closeblock %}
|
||||||
<img style="width: 450px; background-color: #ECEFF1;" src="..."/>
|
<img style="width: 450px; background-color: #ECEFF1;" src="..."/>
|
||||||
{% endif %}
|
{% templatetag openblock %} endif {% templatetag closeblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="product_content_info">
|
<div class="product_content_info">
|
||||||
<h1 class="product_title">{{ page.title }}</h1>
|
<h1 class="product_title">{% templatetag openvariable %} page.title {% templatetag closevariable %}</h1>
|
||||||
<div class="product_description">{{ page.description|richtext }}</div>
|
<div class="product_description">{% templatetag openvariable %} page.description|richtext {% templatetag closevariable %}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if page.tags.all.count %}
|
{% templatetag openblock %} if page.tags.all.count {% templatetag closeblock %}
|
||||||
<div class="tags">
|
<div class="tags">
|
||||||
<h3>Tags</h3>
|
<h3>Tags</h3>
|
||||||
{% for tag in page.tags.all %}
|
{% templatetag openblock %} for tag in page.tags.all {% templatetag closeblock %}
|
||||||
<a href="{% slugurl 'tags' %}?tag={{ tag }}"><button type="button">{{ tag }}</button></a>
|
<a href="{% templatetag openblock %} slugurl 'tags' {% templatetag closeblock %}?tag={% templatetag openvariable %} tag {% templatetag closevariable %}"><button type="button">{% templatetag openvariable %} tag {% templatetag closevariable %}</button></a>
|
||||||
{% endfor %}
|
{% templatetag openblock %} endfor {% templatetag closeblock %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% templatetag openblock %} endif {% templatetag closeblock %}
|
||||||
|
|
||||||
<p><a href="{{ page.get_parent.url }}">Return</a></p>
|
<p><a href="{% templatetag openvariable %} page.get_parent.url {% templatetag closevariable %}">Return</a></p>
|
||||||
|
|
||||||
{% endblock %}
|
{% templatetag openblock %} endblock {% templatetag closeblock %}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
{% extends "base.html" %}
|
{% templatetag openblock %} extends "base.html" {% templatetag closeblock %}
|
||||||
|
|
||||||
{% load wagtailcore_tags wagtailimages_tags %}
|
{% templatetag openblock %} load wagtailcore_tags wagtailimages_tags {% templatetag closeblock %}
|
||||||
|
|
||||||
{% block body_class %}template-productindex{% endblock %}
|
{% templatetag openblock %} block body_class {% templatetag closeblock %}template-productindex{% templatetag openblock %} endblock {% templatetag closeblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% templatetag openblock %} block content {% templatetag closeblock %}
|
||||||
<h1>{{ page.title }}</h1>
|
<h1>{% templatetag openvariable %} page.title {% templatetag closevariable %}</h1>
|
||||||
<div class="row">
|
<div class="row">
|
||||||
{% for post in product %}
|
{% templatetag openblock %} for post in product {% templatetag closeblock %}
|
||||||
{% with post=post.specific %}
|
{% templatetag openblock %} with post=post.specific {% templatetag closeblock %}
|
||||||
<div><a href="{% pageurl post %}">
|
<div><a href="{% templatetag openblock %} pageurl post {% templatetag closeblock %}">
|
||||||
<div class="caption_news">
|
<div class="caption_news">
|
||||||
<h4>{{ post.title }}</h4>
|
<h4>{% templatetag openvariable %} post.title {% templatetag closevariable %}</h4>
|
||||||
<p>{{ post.description|richtext }}</p>
|
<p>{% templatetag openvariable %} post.description|richtext {% templatetag closevariable %}</p>
|
||||||
</div></a>
|
</div></a>
|
||||||
</div>
|
</div>
|
||||||
{% endwith %}
|
{% templatetag openblock %} endwith {% templatetag closeblock %}
|
||||||
{% endfor %}
|
{% templatetag openblock %} endfor {% templatetag closeblock %}
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% templatetag openblock %} endblock {% templatetag closeblock %}
|
||||||
|
|
Ładowanie…
Reference in New Issue