Skip to content
Snippets Groups Projects
Commit f89e0b30 authored by jan.bednarik's avatar jan.bednarik
Browse files

uniweb: Articles block

parent 0907f6dd
Branches
No related tags found
2 merge requests!187Release,!186Uniweb články
......@@ -55,4 +55,5 @@ ALIGN_CSS = {
RIGHT: ["text-right"],
}
ARTICLES_PER_PAGE = 12
ARTICLES_PER_LINE = 3
ARTICLES_PER_PAGE = ARTICLES_PER_LINE * 4
This diff is collapsed.
......@@ -23,6 +23,7 @@ from tuning import help
from .constants import (
ALIGN_CHOICES,
ALIGN_CSS,
ARTICLES_PER_LINE,
ARTICLES_PER_PAGE,
BLACK_ON_WHITE,
COLOR_CHOICES,
......@@ -142,6 +143,35 @@ class PictureListBlock(ColorBlock):
template = "uniweb/blocks/picture_list.html"
class ArticlesBlock(blocks.StructBlock):
page = blocks.PageChooserBlock(
label="sekce článků", page_type=["uniweb.UniwebArticlesIndexPage"]
)
lines = blocks.IntegerBlock(
label="počet řádků",
default=1,
help_text="zobrazí se tři články na řádek",
)
class Meta:
label = "články"
icon = "folder-open-1"
group = "ostatní"
template = "uniweb/blocks/articles.html"
def get_context(self, value, parent_context=None):
context = super().get_context(value, parent_context=parent_context)
count = value["lines"] * ARTICLES_PER_LINE
context["articles"] = (
value["page"]
.get_children()
.live()
.specific()
.order_by("-uniwebarticlepage__date")[:count]
)
return context
class MenuItemBlock(blocks.StructBlock):
name = blocks.CharBlock(label="název")
page = blocks.PageChooserBlock(
......@@ -202,6 +232,7 @@ class UniwebContentMixin(models.Model):
template="uniweb/blocks/table.html",
),
),
("articles", ArticlesBlock()),
],
verbose_name="obsah stránky",
blank=True,
......
{% include "styleguide/2.3.x/article_card_list.html" %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment