added store, and blog module
rodzic
8763bf0853
commit
b8e4cabb0d
Plik binarny nie jest wyświetlany.
|
@ -25,7 +25,7 @@ BASE_DIR = os.path.dirname(PROJECT_DIR)
|
|||
|
||||
INSTALLED_APPS = [
|
||||
"home",
|
||||
"exhibitions",
|
||||
"store",
|
||||
"search",
|
||||
"wagtail.contrib.forms",
|
||||
"wagtail.contrib.redirects",
|
||||
|
@ -37,6 +37,7 @@ INSTALLED_APPS = [
|
|||
"wagtail.images",
|
||||
"wagtail.search",
|
||||
"wagtail.admin",
|
||||
'wagtail.contrib.modeladmin',
|
||||
"wagtail",
|
||||
"modelcluster",
|
||||
"taggit",
|
||||
|
|
|
@ -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,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
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 %}
|
|
@ -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