Skip to content
Snippets Groups Projects
Verified Commit 2d685fc2 authored by jindra12's avatar jindra12
Browse files

Add custom block creator to main page gifts

parent fe14fbd8
No related branches found
No related tags found
2 merge requests!789Release,!786Add custom block creator to main page gifts
Pipeline #13400 passed
from wagtail.blocks import CharBlock, DateBlock, IntegerBlock, ListBlock, StructBlock
from wagtail.blocks import (
CharBlock,
DateBlock,
IntegerBlock,
ListBlock,
RichTextBlock,
StructBlock,
URLBlock,
)
from wagtail.images.blocks import ImageChooserBlock
......@@ -21,3 +29,14 @@ class CrowdfundingRewardBlock(StructBlock):
template = "donate/blocks/crowdfunding_reward_block.html"
icon = "pick"
label = "Odměna"
class CustomContentBlock(StructBlock):
title = CharBlock(label="Nadpis")
content = RichTextBlock(label="Obsah")
link = URLBlock(label="Odkaz")
class Meta:
template = "donate/blocks/custom_content_block.html"
icon = "doc-full"
label = "Obecný blok"
# Generated by Django 4.1.8 on 2023-06-13 22:19
import wagtail.blocks
import wagtail.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("donate", "0026_donateprojectpage_until"),
]
operations = [
migrations.AddField(
model_name="donatehomepage",
name="custom_blocks",
field=wagtail.fields.StreamField(
[
(
"content",
wagtail.blocks.StructBlock(
[
("title", wagtail.blocks.CharBlock(label="Nadpis")),
(
"content",
wagtail.blocks.RichTextBlock(label="Obsah"),
),
("link", wagtail.blocks.URLBlock(label="Odkaz")),
]
),
)
],
blank=True,
use_json_field=True,
verbose_name="Obecné bloky",
),
),
]
......@@ -27,7 +27,7 @@ from shared.models import (
from shared.utils import get_subpage_url, make_promote_panels
from tuning import admin_help
from .blocks import CrowdfundingRewardBlock
from .blocks import CrowdfundingRewardBlock, CustomContentBlock
from .forms import DonateForm
from .utils import get_donated_amount_from_api
......@@ -128,6 +128,13 @@ class DonateHomePage(
# regions section
region_title = models.CharField("podpoř kraj nadpis", max_length=250, blank=True)
region_body = models.TextField("podpoř kraj popis", blank=True)
# custom section
custom_blocks = StreamField(
[("content", CustomContentBlock())],
blank=True,
use_json_field=True,
verbose_name="Obecné bloky",
)
# settings
custom_url_1 = models.URLField("Vlastní odkaz 1", blank=True, null=True)
custom_url_1_text = models.CharField(
......@@ -173,6 +180,7 @@ class DonateHomePage(
[FieldPanel("region_title"), FieldPanel("region_body")],
"podpoř kraj",
),
FieldPanel("custom_blocks"),
]
promote_panels = make_promote_panels(admin_help.build(admin_help.IMPORTANT_TITLE))
......
{% load wagtailcore_tags wagtailimages_tags %}
<div class="container mt-5">
<h2 class="lead page-subheading mb-4">{{ self.title }}</h2>
<p class="mb-4">
{{ self.content|richtext }}
</p>
<a href="{{ self.link }}" class="btn btn-dark btn-lg my-2">Chci vědět více <i class="icon-chevron-right ml-2"></i></a>
</div>
......@@ -132,6 +132,9 @@
</div> <!-- /row -->
</div> <!-- /container -->
{% for content in page.custom_blocks %}
{% include_block content %}
{% endfor %}
</section>
</main>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment