From b8e4cabb0d3f91d7d4a32a61417f3ed0ebbccbd0 Mon Sep 17 00:00:00 2001 From: mtyton Date: Thu, 27 Apr 2023 23:06:28 +0200 Subject: [PATCH 1/2] added store, and blog module --- .../settings/__pycache__/base.cpython-311.pyc | Bin 3774 -> 3796 bytes artel/artel/settings/base.py | 3 +- artel/{exhibitions => blog}/__init__.py | 0 artel/{exhibitions => blog}/admin.py | 0 artel/{exhibitions => blog}/apps.py | 4 +- .../migrations/__init__.py | 0 artel/blog/models.py | 3 + artel/{exhibitions => blog}/tests.py | 0 artel/{exhibitions => blog}/views.py | 0 .../__pycache__/__init__.cpython-311.pyc | Bin 180 -> 0 bytes .../__pycache__/admin.cpython-311.pyc | Bin 235 -> 0 bytes .../__pycache__/apps.cpython-311.pyc | Bin 561 -> 0 bytes .../__pycache__/models.cpython-311.pyc | Bin 2339 -> 0 bytes .../__pycache__/0001_initial.cpython-311.pyc | Bin 2765 -> 0 bytes .../__pycache__/__init__.cpython-311.pyc | Bin 191 -> 0 bytes artel/exhibitions/models.py | 44 -------------- .../exhibitions/exhibition_index_page.html | 17 ------ .../exhibitions/exhibition_page.html | 20 ------ artel/store/admin.py | 48 ++++++++++++++- artel/store/migrations/0001_initial.py | 57 ++++++++++++++++++ artel/store/models.py | 32 +++++++--- 21 files changed, 135 insertions(+), 93 deletions(-) rename artel/{exhibitions => blog}/__init__.py (100%) rename artel/{exhibitions => blog}/admin.py (100%) rename artel/{exhibitions => blog}/apps.py (60%) rename artel/{exhibitions => blog}/migrations/__init__.py (100%) create mode 100644 artel/blog/models.py rename artel/{exhibitions => blog}/tests.py (100%) rename artel/{exhibitions => blog}/views.py (100%) delete mode 100644 artel/exhibitions/__pycache__/__init__.cpython-311.pyc delete mode 100644 artel/exhibitions/__pycache__/admin.cpython-311.pyc delete mode 100644 artel/exhibitions/__pycache__/apps.cpython-311.pyc delete mode 100644 artel/exhibitions/__pycache__/models.cpython-311.pyc delete mode 100644 artel/exhibitions/migrations/__pycache__/0001_initial.cpython-311.pyc delete mode 100644 artel/exhibitions/migrations/__pycache__/__init__.cpython-311.pyc delete mode 100644 artel/exhibitions/models.py delete mode 100644 artel/exhibitions/templates/exhibitions/exhibition_index_page.html delete mode 100644 artel/exhibitions/templates/exhibitions/exhibition_page.html create mode 100644 artel/store/migrations/0001_initial.py diff --git a/artel/artel/settings/__pycache__/base.cpython-311.pyc b/artel/artel/settings/__pycache__/base.cpython-311.pyc index 8e092d9321648735195d67a8c4d55d8b7cd9b7ae..8c9eded831f4c3679dcca584566fe33946be899b 100644 GIT binary patch delta 93 zcmdlddqtLaIWI340}y1HdZe^%k(@PRF qbM%t)^Gb>`lk{@)Q&Mv_FK4Oc5R?#N`oI7q8u&h#Y&PZXWCQ@IHXeHb delta 75 zcmca2yHA#PIWI340}v>CyQXAq>P{wCAAY(d13PUi1CZpdb>KSid|my(BR+CqA*LBsE7LLZ((^WF}>nWaj4;>w|63E2#X%VUwGm iQks)$SHuA{lo5!FWr4&8W=2NF8w?5;u%RM0pb7v|#6L6u diff --git a/artel/exhibitions/__pycache__/apps.cpython-311.pyc b/artel/exhibitions/__pycache__/apps.cpython-311.pyc deleted file mode 100644 index e261fd6bd4baae3d2f64bfbf8ec33136aaa207a9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 561 zcmZutJx{|h5IrX;qO?W8fat)$m?c>m5K@7H1X5LrEsJHao2E+QkT`-eG4LNi`~VQ* z&vdM^GQm_-CMN78RG!{VG>tUPT$^BV5Gpm$jYDsbf6e#i`Kn_Bn z!2wY18mP|Dy$g6WPqP~PuIQMRY#!r~ z1PtSB0b^N^`ij>vK1+#TMph{6k<=HMNEzJAbqp1IgsFPw$FAMy0kZ=!6g;%ML(%79 zH|7I&DiZsgxPo{-Cb3|?UEq&L*d&S)D;mbCn>iSgBuxodUt`?d92u+Q+S=8g8gXNm z+cEX5R{mHC#j4MRR9&$=aZ$35`K{u2+wqcgReO^o2@@S5G=`1Q?>U*%P;&x*;kNpw LPT&6t<(GW|8U2x+ diff --git a/artel/exhibitions/__pycache__/models.cpython-311.pyc b/artel/exhibitions/__pycache__/models.cpython-311.pyc deleted file mode 100644 index 452096e7c1aaada2165c6220c4a3e7790f18937c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2339 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 N^qLLq{>P||?H|W3-1-0j diff --git a/artel/exhibitions/migrations/__pycache__/__init__.cpython-311.pyc b/artel/exhibitions/migrations/__pycache__/__init__.cpython-311.pyc deleted file mode 100644 index 9ce2682c7e3a414bfe6fd1c3c01820def3ee4a5c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 191 zcmZ3^%ge<81h2eYQ$X}%5CH>>P{wCAAY(d13PUi1CZpd2er~FM zZb@ZHex80nWl2VUUO-WPR%&udv3_}CdP!ntPJCifNotNhgiNi-$V|#C$;{6y*3ZpM zFG_?k)=dU}j`w{J;PsikN|70Eo~s AF8}}l diff --git a/artel/exhibitions/models.py b/artel/exhibitions/models.py deleted file mode 100644 index 3bf1e43..0000000 --- a/artel/exhibitions/models.py +++ /dev/null @@ -1,44 +0,0 @@ -from django.db import models -from wagtail.models import ( - Page, - Orderable -) -from wagtail import fields -from wagtail.admin.panels import ( - FieldPanel, - InlinePanel -) -from modelcluster.fields import ParentalKey - - -class ExhibitionIndexPage(Page): - intro = fields.RichTextField(blank=True) - - content_panels = Page.content_panels + [ - FieldPanel('intro') - ] - - -class ExhibitionPage(Page): - exhibition_desc = fields.RichTextField(blank=True) - - content_panels = Page.content_panels + [ - FieldPanel('exhibition_desc'), - InlinePanel('exhibits', label="Exhibits") - ] - - -class Exhibit(Orderable): - page = ParentalKey(ExhibitionPage, on_delete=models.CASCADE, related_name='exhibits') - image = models.ForeignKey( - 'wagtailimages.Image', on_delete=models.CASCADE, related_name='+' - ) - title = models.CharField(max_length=250) - slug = models.SlugField() - exhibit_description = models.TextField(blank=True, default="") - - panels = [ - FieldPanel('image'), - FieldPanel('caption'), - FieldPanel("exhibit_description") - ] diff --git a/artel/exhibitions/templates/exhibitions/exhibition_index_page.html b/artel/exhibitions/templates/exhibitions/exhibition_index_page.html deleted file mode 100644 index d58f2ff..0000000 --- a/artel/exhibitions/templates/exhibitions/exhibition_index_page.html +++ /dev/null @@ -1,17 +0,0 @@ -{% extends "base.html" %} - -{% load wagtailcore_tags %} - -{% block body_class %}template-blogindexpage{% endblock %} - -{% block content %} -

{{ page.title }}

- -
{{ page.intro|richtext }}
- - {% for exhibition in page.get_children %} -

{{ exhibition.title }}

- {{ exhibition.specific.exhibition_desc }} - {% endfor %} - -{% endblock %} \ No newline at end of file diff --git a/artel/exhibitions/templates/exhibitions/exhibition_page.html b/artel/exhibitions/templates/exhibitions/exhibition_page.html deleted file mode 100644 index 318c5c4..0000000 --- a/artel/exhibitions/templates/exhibitions/exhibition_page.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "base.html" %} - -{% load wagtailcore_tags wagtailimages_tags %} - -{% block body_class %}template-blogpage{% endblock %} - -{% block content %} -

{{ page.title }}

-
- {% for item in page.exhibits.all %} -
- {% image item.image max-320x200 %} -

{{ item.caption }}

-
- {% endfor %} -
- - - -{% endblock %} \ No newline at end of file diff --git a/artel/store/admin.py b/artel/store/admin.py index 8c38f3f..ffe0108 100644 --- a/artel/store/admin.py +++ b/artel/store/admin.py @@ -1,3 +1,47 @@ -from django.contrib import admin +from django.forms import fields -# Register your models here. +from wagtail.contrib.modeladmin.options import ( + ModelAdmin, + ModelAdminGroup, + modeladmin_register +) +from wagtail.admin.forms.models import WagtailAdminModelForm + +from store import models + + +class ProductConfigAdmin(ModelAdmin): + model = models.ProductConfig + list_display = ("author__name", "color", "price") + search_fields = ("author__name", "color", "price") + + +class ProductTemplateAdmin(ModelAdmin): + model = models.ProductTemplate + list_display = ("title", ) + + +class ProductAdminForm(WagtailAdminModelForm): + + template_title = fields.CharField() + template_code = fields.CharField() + template_description = fields.CharField() + + class Meta: + fields = ("template_title", "template_code", "template_description") + model = models.Product + + +class ProductAdmin(ModelAdmin): + model = models.Product + form = ProductAdminForm + + +class StoreAdminGroup(ModelAdminGroup): + menu_label = "Store" + menu_icon = 'folder-open-inverse' + menu_order = 200 + items = (ProductConfigAdmin, ProductTemplateAdmin, ProductAdmin) + + +modeladmin_register(StoreAdminGroup) diff --git a/artel/store/migrations/0001_initial.py b/artel/store/migrations/0001_initial.py new file mode 100644 index 0000000..046c795 --- /dev/null +++ b/artel/store/migrations/0001_initial.py @@ -0,0 +1,57 @@ +# Generated by Django 4.1.8 on 2023-04-25 22:22 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='ProductAuthor', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ], + ), + migrations.CreateModel( + name='ProductTemplate', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=255)), + ('code', models.CharField(max_length=255)), + ('description', models.TextField()), + ], + ), + migrations.CreateModel( + name='ProductImage', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('image', models.ImageField(upload_to='')), + ('template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='store.producttemplate')), + ], + ), + migrations.CreateModel( + name='ProductConfig', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('color', models.CharField(max_length=255)), + ('size', models.CharField(max_length=50)), + ('price', models.FloatField()), + ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='store.productauthor')), + ], + ), + migrations.CreateModel( + name='Product', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('config', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='store.productconfig')), + ('template', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='store.producttemplate')), + ], + ), + ] diff --git a/artel/store/models.py b/artel/store/models.py index cf5be90..8851557 100644 --- a/artel/store/models.py +++ b/artel/store/models.py @@ -1,16 +1,34 @@ from django.db import models -class Product(models.Model): - template = models.ForeignKey("exhibitions.Exhibit", on_delete=models.CASCADE) - - -class ProductSource(models.Model): +class ProductAuthor(models.Model): name = models.CharField(max_length=255) + # TODO - author contact info? maybe foreignkey with user + +class ProductTemplate(models.Model): + title = models.CharField(max_length=255) + code = models.CharField(max_length=255) + description = models.TextField() + + def get_images(self): + return self.images.objects.all().values_list("image") + + +class ProductImage(models.Model): + template = models.ForeignKey( + ProductTemplate, on_delete=models.CASCADE, related_name="images" + ) + image = models.ImageField() class ProductConfig(models.Model): - source = models.ForeignKey(ProductSource, on_delete=models.CASCADE) + author = models.ForeignKey(ProductAuthor, on_delete=models.CASCADE) color = models.CharField(max_length=255) - + size = models.CharField(max_length=50) price = models.FloatField() + + +class Product(models.Model): + template = models.ForeignKey(ProductTemplate, on_delete=models.CASCADE) + config = models.ForeignKey(ProductConfig, on_delete=models.CASCADE) + From d9ee2c8c812393fda32b9b0e0d37d0fd32cb9c1c Mon Sep 17 00:00:00 2001 From: mtyton Date: Sat, 29 Apr 2023 11:51:04 +0200 Subject: [PATCH 2/2] added blog section --- .../settings/__pycache__/base.cpython-311.pyc | Bin 3796 -> 3862 bytes artel/artel/settings/base.py | 3 ++ artel/artel/templates/base.html | 11 +++- .../templates/menu/custom_main_menu.html | 14 +++++ artel/blog/migrations/0001_initial.py | 48 ++++++++++++++++++ artel/blog/models.py | 46 ++++++++++++++++- artel/blog/templates/blog/blog_page.html | 18 +++++++ artel/home/templates/home/home_page.html | 4 +- artel/requirements.txt | 1 + 9 files changed, 141 insertions(+), 4 deletions(-) create mode 100644 artel/artel/templates/menu/custom_main_menu.html create mode 100644 artel/blog/migrations/0001_initial.py create mode 100644 artel/blog/templates/blog/blog_page.html diff --git a/artel/artel/settings/__pycache__/base.cpython-311.pyc b/artel/artel/settings/__pycache__/base.cpython-311.pyc index 8c9eded831f4c3679dcca584566fe33946be899b..140581b6ed619f8f26811c0760b0219d66cf29fe 100644 GIT binary patch delta 217 zcmca2J57#vIWI340}!mX_DOlRk@q~ah~zDnjQrfxTdc(;`9-O>Sdwz`(9x1H= diff --git a/artel/artel/settings/base.py b/artel/artel/settings/base.py index d7fe32a..8663caf 100644 --- a/artel/artel/settings/base.py +++ b/artel/artel/settings/base.py @@ -26,6 +26,7 @@ BASE_DIR = os.path.dirname(PROJECT_DIR) INSTALLED_APPS = [ "home", "store", + "blog", "search", "wagtail.contrib.forms", "wagtail.contrib.redirects", @@ -39,6 +40,7 @@ INSTALLED_APPS = [ "wagtail.admin", 'wagtail.contrib.modeladmin', "wagtail", + "wagtailmenus", "modelcluster", "taggit", "django.contrib.admin", @@ -75,6 +77,7 @@ TEMPLATES = [ "django.template.context_processors.request", "django.contrib.auth.context_processors.auth", "django.contrib.messages.context_processors.messages", + 'wagtailmenus.context_processors.wagtailmenus', ], }, }, diff --git a/artel/artel/templates/base.html b/artel/artel/templates/base.html index 28f6d95..1b32201 100644 --- a/artel/artel/templates/base.html +++ b/artel/artel/templates/base.html @@ -1,4 +1,5 @@ {% load static wagtailcore_tags wagtailuserbar %} +{% load menu_tags %} @@ -33,8 +34,14 @@ {% wagtailuserbar %} - - {% block content %}{% endblock %} +
+
+ {% main_menu template="menu/custom_main_menu.html" %} +
+
+ {% block content %}{% endblock %} +
+
{# Global javascript #} diff --git a/artel/artel/templates/menu/custom_main_menu.html b/artel/artel/templates/menu/custom_main_menu.html new file mode 100644 index 0000000..939c5c8 --- /dev/null +++ b/artel/artel/templates/menu/custom_main_menu.html @@ -0,0 +1,14 @@ +
    + {% for item in menu_items %} +
  • + {{ item.text }} + {% if item.sub_menu %} + + {% endif %} +
  • + {% endfor %} +
\ No newline at end of file diff --git a/artel/blog/migrations/0001_initial.py b/artel/blog/migrations/0001_initial.py new file mode 100644 index 0000000..1b511ac --- /dev/null +++ b/artel/blog/migrations/0001_initial.py @@ -0,0 +1,48 @@ +# Generated by Django 4.1.8 on 2023-04-28 20:41 + +import django.core.validators +from django.db import migrations, models +import django.db.models.deletion +import modelcluster.fields +import wagtail.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailcore', '0083_workflowcontenttype'), + ('wagtailimages', '0025_alter_image_file_alter_rendition_file'), + ] + + operations = [ + migrations.CreateModel( + name='BlogPage', + 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')), + ('create_date', models.DateField(auto_now_add=True)), + ('edit_date', models.DateField(auto_now=True)), + ('body', wagtail.fields.RichTextField()), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + migrations.CreateModel( + name='BlogPageGalleryImage', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('sort_order', models.IntegerField(blank=True, editable=False, null=True)), + ('caption', models.CharField(blank=True, max_length=250)), + ('order', models.IntegerField(validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(1000)])), + ('image', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='+', to='wagtailimages.image')), + ('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='gallery_images', to='blog.blogpage')), + ], + options={ + 'ordering': ['sort_order'], + 'abstract': False, + }, + ), + ] diff --git a/artel/blog/models.py b/artel/blog/models.py index 71a8362..7ab6502 100644 --- a/artel/blog/models.py +++ b/artel/blog/models.py @@ -1,3 +1,47 @@ from django.db import models +from django.core.validators import ( + MinValueValidator, + MaxValueValidator +) -# Create your models here. +from wagtail.models import Page, Orderable +from wagtail.fields import RichTextField +from wagtail.admin.panels import ( + FieldPanel, + InlinePanel +) +from wagtail.search import index +from modelcluster.fields import ParentalKey + + +class BlogPage(Page): + create_date = models.DateField(auto_now_add=True) + edit_date = models.DateField(auto_now=True) + + body = RichTextField() + + content_panels = Page.content_panels + [ + FieldPanel("body"), + InlinePanel("gallery_images") + ] + + +class BlogPageGalleryImage(Orderable): + page = ParentalKey(BlogPage, on_delete=models.CASCADE, related_name='gallery_images') + image = models.ForeignKey( + 'wagtailimages.Image', on_delete=models.CASCADE, related_name='+' + ) + caption = models.CharField(blank=True, max_length=250) + + order = models.IntegerField( + validators=[ + MinValueValidator(0), + MaxValueValidator(1000) + ] + ) + + panels = [ + FieldPanel('order'), + FieldPanel('image'), + FieldPanel('caption'), + ] diff --git a/artel/blog/templates/blog/blog_page.html b/artel/blog/templates/blog/blog_page.html new file mode 100644 index 0000000..89d786b --- /dev/null +++ b/artel/blog/templates/blog/blog_page.html @@ -0,0 +1,18 @@ +{% extends "base.html" %} + +{% load wagtailcore_tags wagtailimages_tags %} + +{% block content %} +

{{ page.title }}

+

{{ page.date }}

+ +
{{ page.body|richtext }}
+ + {% for item in page.gallery_images.all %} +
+ {% image item.image fill-320x240 %} +

{{ item.caption }}

+
+ {% endfor %} + +{% endblock %} diff --git a/artel/home/templates/home/home_page.html b/artel/home/templates/home/home_page.html index 85c0021..c923639 100644 --- a/artel/home/templates/home/home_page.html +++ b/artel/home/templates/home/home_page.html @@ -5,5 +5,7 @@ {% block body_class %}template-homepage{% endblock %} {% block content %} - {{ page.body|richtext }} +
+ {{ page.body|richtext }} +
{% endblock %} \ No newline at end of file diff --git a/artel/requirements.txt b/artel/requirements.txt index f0b8e40..adb50bf 100644 --- a/artel/requirements.txt +++ b/artel/requirements.txt @@ -1,2 +1,3 @@ Django>=4.1,<4.2 wagtail>=4.2,<4.3 +wagtailmenus>=3.15, <=3.1.7