Remade blog gallery using wagtail-simple-gallery
rodzic
cfee29d09d
commit
85394433d2
|
@ -72,6 +72,7 @@ INSTALLED_APPS = [
|
||||||
"django_celery_results",
|
"django_celery_results",
|
||||||
"django_celery_beat",
|
"django_celery_beat",
|
||||||
"easy_thumbnails",
|
"easy_thumbnails",
|
||||||
|
'wagtail_simple_gallery',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
# Generated by Django 4.1.11 on 2023-09-28 23:29
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("wagtailcore", "0083_workflowcontenttype"),
|
||||||
|
("blog", "0001_initial"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="blogpage",
|
||||||
|
name="collection",
|
||||||
|
field=models.ForeignKey(
|
||||||
|
blank=True,
|
||||||
|
null=True,
|
||||||
|
on_delete=django.db.models.deletion.SET_NULL,
|
||||||
|
related_name="+",
|
||||||
|
to="wagtailcore.collection",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -4,6 +4,8 @@ from django.core.validators import (
|
||||||
MaxValueValidator
|
MaxValueValidator
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from wagtail.core.models import Collection
|
||||||
|
|
||||||
from wagtail.models import Page, Orderable
|
from wagtail.models import Page, Orderable
|
||||||
from wagtail.fields import RichTextField
|
from wagtail.fields import RichTextField
|
||||||
from wagtail.admin.panels import (
|
from wagtail.admin.panels import (
|
||||||
|
@ -19,12 +21,22 @@ class BlogPage(Page):
|
||||||
edit_date = models.DateField(auto_now=True)
|
edit_date = models.DateField(auto_now=True)
|
||||||
|
|
||||||
body = RichTextField()
|
body = RichTextField()
|
||||||
|
collection = models.ForeignKey(
|
||||||
|
Collection,
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
on_delete=models.SET_NULL,
|
||||||
|
related_name='+'
|
||||||
|
)
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
FieldPanel("body"),
|
FieldPanel("body"),
|
||||||
InlinePanel("gallery_images")
|
FieldPanel("collection")
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def get_collection_name(self):
|
||||||
|
return self.collection.name if self.collection else None
|
||||||
|
|
||||||
|
|
||||||
class BlogPageGalleryImage(Orderable):
|
class BlogPageGalleryImage(Orderable):
|
||||||
page = ParentalKey(BlogPage, on_delete=models.CASCADE, related_name='gallery_images')
|
page = ParentalKey(BlogPage, on_delete=models.CASCADE, related_name='gallery_images')
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% load wagtailcore_tags wagtailimages_tags %}
|
{% load wagtailcore_tags wagtailimages_tags %}
|
||||||
|
{% load wagtailsimplegallery_tags %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>{{ page.title }}</h1>
|
<h1>{{ page.title }}</h1>
|
||||||
|
@ -8,11 +9,6 @@
|
||||||
|
|
||||||
<div class="body">{{ page.body|richtext }}</div>
|
<div class="body">{{ page.body|richtext }}</div>
|
||||||
|
|
||||||
{% for item in page.gallery_images.all %}
|
{% simple_gallery collection=page.get_collection_name %}
|
||||||
<div style="float: left; margin: 10px">
|
|
||||||
{% image item.image fill-320x240 %}
|
|
||||||
<p>{{ item.caption }}</p>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -16,3 +16,4 @@ num2words==0.5.12
|
||||||
sentry-sdk==1.28.0
|
sentry-sdk==1.28.0
|
||||||
pandas==2.0.3
|
pandas==2.0.3
|
||||||
wagtail-localize==1.5.2
|
wagtail-localize==1.5.2
|
||||||
|
wagtail-simple-gallery==0.9.1
|
||||||
|
|
Ładowanie…
Reference in New Issue