diff --git a/artel/artel/static/images/icons/cart.svg b/artel/artel/static/images/icons/cart.svg
new file mode 100644
index 0000000..486adb1
--- /dev/null
+++ b/artel/artel/static/images/icons/cart.svg
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/artel/artel/templates/menu/custom_main_menu.html b/artel/artel/templates/menu/custom_main_menu.html
index 8315b39..3c10bd5 100644
--- a/artel/artel/templates/menu/custom_main_menu.html
+++ b/artel/artel/templates/menu/custom_main_menu.html
@@ -21,5 +21,4 @@
-
diff --git a/artel/artel/urls.py b/artel/artel/urls.py
index c2e8a0c..b3d57c5 100644
--- a/artel/artel/urls.py
+++ b/artel/artel/urls.py
@@ -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")
]
diff --git a/artel/store/migrations/0002_product_available_producttemplate_tags_and_more.py b/artel/store/migrations/0002_product_available_producttemplate_tags_and_more.py
new file mode 100644
index 0000000..e5aba1c
--- /dev/null
+++ b/artel/store/migrations/0002_product_available_producttemplate_tags_and_more.py
@@ -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',),
+ ),
+ ]
diff --git a/artel/store/models.py b/artel/store/models.py
index 8877886..d770de2 100644
--- a/artel/store/models.py
+++ b/artel/store/models.py
@@ -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")
+ ]
diff --git a/artel/store/templates/store/partials/product_card.html b/artel/store/templates/store/partials/product_card.html
new file mode 100644
index 0000000..f6d13db
--- /dev/null
+++ b/artel/store/templates/store/partials/product_card.html
@@ -0,0 +1,12 @@
+{% load static %}
+
+
diff --git a/artel/store/templates/store/product_list_page.html b/artel/store/templates/store/product_list_page.html
new file mode 100644
index 0000000..9628f27
--- /dev/null
+++ b/artel/store/templates/store/product_list_page.html
@@ -0,0 +1,19 @@
+{% extends 'base.html'%}
+
+
+{% block content %}
+
+
+
+
+ {% include 'store/partials/product_card.html' %}
+
+
+ {% include 'store/partials/product_card.html' %}
+
+
+ {% include 'store/partials/product_card.html' %}
+
+
+
+{% endblock %}
diff --git a/artel/store/templates/store/shopping_cart.html b/artel/store/templates/store/shopping_cart.html
new file mode 100644
index 0000000..e69de29
diff --git a/artel/store/views.py b/artel/store/views.py
deleted file mode 100644
index 91ea44a..0000000
--- a/artel/store/views.py
+++ /dev/null
@@ -1,3 +0,0 @@
-from django.shortcuts import render
-
-# Create your views here.