commit
8ea7141cce
Plik binarny nie jest wyświetlany.
|
@ -25,7 +25,8 @@ BASE_DIR = os.path.dirname(PROJECT_DIR)
|
|||
|
||||
INSTALLED_APPS = [
|
||||
"home",
|
||||
"exhibitions",
|
||||
"store",
|
||||
"blog",
|
||||
"search",
|
||||
"wagtail.contrib.forms",
|
||||
"wagtail.contrib.redirects",
|
||||
|
@ -37,7 +38,9 @@ INSTALLED_APPS = [
|
|||
"wagtail.images",
|
||||
"wagtail.search",
|
||||
"wagtail.admin",
|
||||
'wagtail.contrib.modeladmin',
|
||||
"wagtail",
|
||||
"wagtailmenus",
|
||||
"modelcluster",
|
||||
"taggit",
|
||||
"django.contrib.admin",
|
||||
|
@ -74,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',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{% load static wagtailcore_tags wagtailuserbar %}
|
||||
{% load menu_tags %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
@ -33,8 +34,14 @@
|
|||
|
||||
<body class="{% block body_class %}{% endblock %}">
|
||||
{% wagtailuserbar %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
<div class="row">
|
||||
<div class="col s3">
|
||||
{% main_menu template="menu/custom_main_menu.html" %}
|
||||
</div>
|
||||
<div class="col s9">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# Global javascript #}
|
||||
<script type="text/javascript" src="{% static 'js/artel.js' %}"></script>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<ul>
|
||||
{% for item in menu_items %}
|
||||
<li class="{{ item.active_class }}">
|
||||
<a href="{{ item.href }}">{{ item.text }}</a>
|
||||
{% if item.sub_menu %}
|
||||
<ul class="sub-menu">
|
||||
{% for sub_item in item.sub_menu.items %}
|
||||
<li class="{{ sub_item.active_class }}"><a href="{{ sub_item.href }}">{{ sub_item.text }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
|
@ -1,6 +1,6 @@
|
|||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ExhibitionsConfig(AppConfig):
|
||||
class BlogConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'exhibitions'
|
||||
name = 'blog'
|
|
@ -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,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -0,0 +1,47 @@
|
|||
from django.db import models
|
||||
from django.core.validators import (
|
||||
MinValueValidator,
|
||||
MaxValueValidator
|
||||
)
|
||||
|
||||
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'),
|
||||
]
|
|
@ -0,0 +1,18 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load wagtailcore_tags wagtailimages_tags %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ page.title }}</h1>
|
||||
<p class="meta">{{ page.date }}</p>
|
||||
|
||||
<div class="body">{{ page.body|richtext }}</div>
|
||||
|
||||
{% for item in page.gallery_images.all %}
|
||||
<div style="float: left; margin: 10px">
|
||||
{% image item.image fill-320x240 %}
|
||||
<p>{{ item.caption }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
Plik binarny nie jest wyświetlany.
|
@ -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")
|
||||
]
|
|
@ -1,17 +0,0 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load wagtailcore_tags %}
|
||||
|
||||
{% block body_class %}template-blogindexpage{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ page.title }}</h1>
|
||||
|
||||
<div class="intro">{{ page.intro|richtext }}</div>
|
||||
|
||||
{% for exhibition in page.get_children %}
|
||||
<h2><a href="{% pageurl exhibition %}">{{ exhibition.title }}</a></h2>
|
||||
{{ exhibition.specific.exhibition_desc }}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
|
@ -1,20 +0,0 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load wagtailcore_tags wagtailimages_tags %}
|
||||
|
||||
{% block body_class %}template-blogpage{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ page.title }}</h1>
|
||||
<div>
|
||||
{% for item in page.exhibits.all %}
|
||||
<div style="float: left; margin: 10px">
|
||||
{% image item.image max-320x200 %}
|
||||
<p>{{ item.caption }}</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div><a href="{{ page.get_parent.url }}">Return to blog</a></div>
|
||||
|
||||
{% endblock %}
|
|
@ -5,5 +5,7 @@
|
|||
{% block body_class %}template-homepage{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ page.body|richtext }}
|
||||
<div>
|
||||
{{ page.body|richtext }}
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -1,2 +1,3 @@
|
|||
Django>=4.1,<4.2
|
||||
wagtail>=4.2,<4.3
|
||||
wagtailmenus>=3.15, <=3.1.7
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -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)
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue