initial store sketch is ready now

pull/2/head
mtyton 2023-05-14 00:23:19 +02:00
rodzic 0938a66022
commit 0ee9653d8e
9 zmienionych plików z 117 dodań i 8 usunięć

Wyświetl plik

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cart" viewBox="0 0 16 16">
<path d="M0 1.5A.5.5 0 0 1 .5 1H2a.5.5 0 0 1 .485.379L2.89 3H14.5a.5.5 0 0 1 .491.592l-1.5 8A.5.5 0 0 1 13 12H4a.5.5 0 0 1-.491-.408L2.01 3.607 1.61 2H.5a.5.5 0 0 1-.5-.5zM3.102 4l1.313 7h8.17l1.313-7H3.102zM5 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm7 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm-7 1a1 1 0 1 1 0 2 1 1 0 0 1 0-2zm7 0a1 1 0 1 1 0 2 1 1 0 0 1 0-2z"/>
</svg>

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 476 B

Wyświetl plik

@ -21,5 +21,4 @@
</ul>
<hr>
</div>

Wyświetl plik

@ -12,7 +12,7 @@ urlpatterns = [
path("django-admin/", admin.site.urls),
path("admin/", include(wagtailadmin_urls)),
path("documents/", include(wagtaildocs_urls)),
path("search/", search_views.search, name="search"),
path("search/", search_views.search, name="search")
]

Wyświetl plik

@ -0,0 +1,45 @@
# Generated by Django 4.1.9 on 2023-05-13 21:57
from django.db import migrations, models
import django.db.models.deletion
import taggit.managers
import wagtail.fields
class Migration(migrations.Migration):
dependencies = [
('taggit', '0005_auto_20220424_2025'),
('wagtailcore', '0083_workflowcontenttype'),
('store', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='product',
name='available',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='producttemplate',
name='tags',
field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'),
),
migrations.AlterField(
model_name='product',
name='template',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='products', to='store.producttemplate'),
),
migrations.CreateModel(
name='ProductListPage',
fields=[
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.page')),
('description', wagtail.fields.RichTextField(blank=True)),
('tags', taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags')),
],
options={
'abstract': False,
},
bases=('wagtailcore.page',),
),
]

Wyświetl plik

@ -6,11 +6,18 @@ from wagtail.admin.panels import (
FieldPanel,
InlinePanel
)
from wagtail.models import Orderable
from wagtail.models import (
Orderable,
Page
)
from wagtail import fields as wagtail_fields
from taggit.managers import TaggableManager
from taggit.models import Tag
class ProductAuthor(models.Model):
name = models.CharField(max_length=255)
# TODO - add author contact data
def __str__(self):
return self.name
@ -49,6 +56,8 @@ class ProductTemplate(ClusterableModel):
title = models.CharField(max_length=255)
code = models.CharField(max_length=255)
description = models.TextField()
tags = TaggableManager()
def __str__(self):
return self.title
@ -59,6 +68,7 @@ class ProductTemplate(ClusterableModel):
panels = [
FieldPanel("category"),
FieldPanel("author"),
FieldPanel("family"),
FieldPanel('title'),
FieldPanel('code'),
FieldPanel('description'),
@ -74,13 +84,15 @@ class ProductImage(models.Model):
class Product(ClusterableModel):
template = models.ForeignKey(ProductTemplate, on_delete=models.CASCADE)
template = models.ForeignKey(ProductTemplate, on_delete=models.CASCADE, related_name="products")
price = models.FloatField()
available = models.BooleanField(default=True)
panels = [
FieldPanel("template"),
FieldPanel("price"),
InlinePanel("param_values")
InlinePanel("param_values"),
InlinePanel("available")
]
@property
@ -92,3 +104,25 @@ class TemplateParamValue(models.Model):
param = models.ForeignKey(ProductCategoryParam, on_delete=models.CASCADE)
product = ParentalKey(Product, on_delete=models.CASCADE, related_name="param_values")
value = models.CharField(max_length=255)
class ProductListPage(Page):
# TODO add filters
description = wagtail_fields.RichTextField(blank=True)
tags = TaggableManager(blank=True)
def _get_items(self):
if self.tags:
return Product.objects.filter(available=True, template__tags__in=self.tags.all())
return Product.objects.filter(available=True)
def get_context(self, request):
context = super().get_context(request)
context["items"] = self._get_items()
return context
content_panels = Page.content_panels + [
FieldPanel("description"),
FieldPanel("tags")
]

Wyświetl plik

@ -0,0 +1,12 @@
{% load static %}
<div class="card" style="width: 15rem;">
<img class="card-img-top" src="..." alt="Card image cap">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<a href="#" class="btn btn-primary">Details</a>
<a href="#" class="btn btn-success">
<img src = "{% static 'images/icons/cart.svg' %}" alt="Koszyk"/>
</a>
</div>
</div>

Wyświetl plik

@ -0,0 +1,19 @@
{% extends 'base.html'%}
{% block content %}
<div class="container">
<div class="row mb-3">
<div class="col-sm">
{% include 'store/partials/product_card.html' %}
</div>
<div class="col-sm">
{% include 'store/partials/product_card.html' %}
</div>
<div class="col-sm">
{% include 'store/partials/product_card.html' %}
</div>
</div>
</div>
{% endblock %}

Wyświetl plik

@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.