added blog section
rodzic
b8e4cabb0d
commit
d9ee2c8c81
Plik binarny nie jest wyświetlany.
|
@ -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',
|
||||
],
|
||||
},
|
||||
},
|
||||
|
|
|
@ -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>
|
|
@ -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,
|
||||
},
|
||||
),
|
||||
]
|
|
@ -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'),
|
||||
]
|
||||
|
|
|
@ -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 %}
|
|
@ -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
|
||||
|
|
Ładowanie…
Reference in New Issue