Skip to content
Snippets Groups Projects
Commit fac49f1b authored by Tomáš Valenta's avatar Tomáš Valenta
Browse files

add option for multiple home support sections

parent 070d0c58
Branches
No related tags found
2 merge requests!826add option for multiple home support sections,!825Add option for multiple donation homepage support sections
Pipeline #14604 passed
# Generated by Django 4.1.10 on 2023-09-13 18:47
from django.db import migrations, models
import wagtail.fields
class Migration(migrations.Migration):
dependencies = [
("donate", "0030_donateprojectindexpage_heading"),
]
operations = [
migrations.AddField(
model_name="donateprojectindexpage",
name="support_description",
field=wagtail.fields.RichTextField(
default="", verbose_name="Podpoř projekt popis"
),
preserve_default=False,
),
migrations.AddField(
model_name="donateprojectindexpage",
name="support_heading",
field=models.CharField(
default="", max_length=32, verbose_name="Podpoř projekt nadpis"
),
preserve_default=False,
),
migrations.AddField(
model_name="donateprojectindexpage",
name="support_position",
field=models.IntegerField(
default=0,
help_text="Čím nižší číslo, tím výš se seznam projektů zobrazí.",
verbose_name="Podpoř projekt pozice",
),
),
]
# Generated by Django 4.1.10 on 2023-09-13 19:53
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("donate", "0031_donateprojectindexpage_support_description_and_more"),
]
operations = [
migrations.RemoveField(
model_name="donateprojectindexpage",
name="support_position",
),
]
# Generated by Django 4.1.10 on 2023-09-13 20:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("donate", "0032_remove_donateprojectindexpage_support_position"),
]
operations = [
migrations.AddField(
model_name="donateprojectindexpage",
name="support_position",
field=models.IntegerField(
default=0,
help_text="Čím nižší číslo, tím výš se seznam projektů zobrazí.",
verbose_name="Podpoř projekt pozice",
),
),
]
......@@ -261,8 +261,9 @@ class DonateHomePage(
def info_page_url(self):
return get_subpage_url(self, DonateInfoPage)
@cached_property
def project_indexes(self):
return self.get_descendants().type(DonateProjectIndexPage).live().all()
return DonateProjectIndexPage.objects.child_of(self).live()
@cached_property
def regions_page_url(self):
......@@ -279,14 +280,23 @@ class DonateHomePage(
self.get_descendants().type(DonateRegionPage).live().specific()
)
context["projects"] = (
self.get_descendants()
.type(DonateProjectPage)
.live()
.specific()
.order_by("-donateprojectpage__date")[:3]
context["project_support_blocks"] = []
for project_index in self.project_indexes.order_by("support_position"):
block = {}
block["index"] = project_index
block["projects"] = (
DonateProjectPage.
objects.
child_of(project_index).
live().
specific().
order_by("-date")[:3]
)
context["project_support_blocks"].append(block)
return context
......@@ -394,10 +404,26 @@ class DonateProjectIndexPage(
heading = models.CharField("Hlavní nadpis", max_length=32)
support_heading = models.CharField("Podpoř projekt nadpis", max_length=32)
support_description = RichTextField("Podpoř projekt popis")
support_position = models.IntegerField(
"Podpoř projekt pozice",
help_text="Čím nižší číslo, tím výš se seznam projektů zobrazí.",
default=0,
)
### PANELS
content_panels = Page.content_panels + [
FieldPanel("heading"),
MultiFieldPanel(
[
FieldPanel("support_heading"),
FieldPanel("support_description"),
FieldPanel("support_position"),
],
"Informace v sekci 'podpoř projekt' na homepage",
),
]
promote_panels = make_promote_panels()
......
......@@ -112,24 +112,24 @@
</div> <!-- /container -->
</section>
{% if page.has_projects %}
<section class="section--{% get_section_kind %}" id="projekty">
{% for project_support_block in project_support_blocks %}
{% if project_support_block.projects|length != 0 %}
<section class="section--{% get_section_kind %}" id="projekty-{{ project_support_block.index.id }}">
<div class="container">
<h2 class="lead page-subheading mb-4">{{ project_support_block.index.support_heading }}</h2>
<p class="mb-4">{{ project_support_block.index.support_description|richtext }}</p>
<h2 class="lead page-subheading mb-4">{{ page.project_title }}</h2>
<p class="mb-4">{{ page.project_body }}</p>
<div class="row projects mb-4">
{% for project in projects %}
{% for project in project_support_block.projects %}
{% include "donate/project_snippet.html" %}
{% endfor %}
</div> <!-- /row -->
<a href="{{ page.projects_page_url }}" class="btn btn-dark btn-lg my-2">Všechny projekty a kampaně <i class="icon-chevron-right ml-2"></i></a>
<a href="{{ project_support_block.index.url }}" class="btn btn-dark btn-lg my-2">Všechny projekty a kampaně <i class="icon-chevron-right ml-2"></i></a>
</div> <!-- /container -->
</section>
{% endif %}
{% endfor %}
{% for content in page.custom_blocks %}
<section class="section--{% get_section_kind %} section--custom" id="custom">
......
# Base variables
DATABASE_URL=postgres://majak:majak@localhost:5432/majak
OIDC_RP_REALM_URL=http://localhost:8080/realms/master/
OIDC_RP_CLIENT_ID=majak
OIDC_RP_CLIENT_SECRET=KFo7EfYPTrwdWxykl9hAf7WgwL8smYzP
# Production
DJANGO_SECRET_KEY=
DJANGO_ALLOWED_HOSTS=
CELERY_BROKER_URL=
CELERY_RESULT_BACKEND=
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment