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

elections2021: Refactor constants

parent 0b848a36
No related branches found
No related tags found
2 merge requests!216Release,!215Volby
WHITE = "white"
BLACK = "black"
YELLOW = "yellow"
GREEN = "green"
STYLE_CHOICES = (
(WHITE, "bílé pozadí"),
(BLACK, "černé pozadí"),
(YELLOW, "žluté pozadí"),
(GREEN, "zelené pozadí"),
)
STYLE_CSS = {
WHITE: "",
BLACK: "emphasized-black",
YELLOW: "emphasized-lemon",
GREEN: "emphasized-acidgreen",
}
RICH_TEXT_FEATURES = [
"h2",
"h3",
"h4",
"bold",
"italic",
"superscript",
"subscript",
"strikethrough",
"ul-elections2021",
"ol-elections2021",
"blockquote-elections2021",
"link",
"image",
"document-link",
]
ARTICLES_PER_PAGE = 9
# cílovky
CHILDLESS = "childless"
PARENT = "parent"
MATURE = "mature"
GRANDPARENT = "grandparent"
WORKING_SENIOR = "working_senior"
STUDENT = "student"
SELF_EMPLOYED = "self_employed"
SOCIALLY_WEAK = "socially_weak"
NATURE = "nature"
SPORT = "sport"
HEALTH = "health"
CULTURE = "culture"
COMPUTERS = "computers"
COUNTRYSIDE = "countryside"
HOUSING = "housing"
EDUCATION = "education"
TARGET_CHOICES = (
(CHILDLESS, "bezdětní"),
(PARENT, "rodiče"),
(MATURE, "zralý"),
(GRANDPARENT, "prarodiče"),
(WORKING_SENIOR, "pracující senioři"),
(STUDENT, "studenti"),
(SELF_EMPLOYED, "OSVČ"),
(SOCIALLY_WEAK, "sociálně slabí"),
(NATURE, "příroda"),
(SPORT, "sport"),
(HEALTH, "zdraví"),
(CULTURE, "kultura"),
(COMPUTERS, "počítače"),
(COUNTRYSIDE, "venkov"),
(HOUSING, "bydlení"),
(EDUCATION, "vzdělávání"),
)
......@@ -13,7 +13,13 @@ from wagtailmetadata.models import MetadataPageMixin
from shared.models import ArticleMixin, SubpageMixin
from shared.utils import get_subpage_url
ARTICLES_PER_PAGE = 9
from .constants import (
ARTICLES_PER_PAGE,
RICH_TEXT_FEATURES,
STYLE_CHOICES,
STYLE_CSS,
WHITE,
)
class LinkBlock(blocks.StructBlock):
......@@ -73,39 +79,6 @@ class Elections2021ArticleTag(TaggedItemBase):
class Elections2021ArticlePage(ArticleMixin, SubpageMixin, MetadataPageMixin, Page):
WHITE = "white"
BLACK = "black"
YELLOW = "yellow"
GREEN = "green"
STYLE_CHOICES = (
(WHITE, "bílé pozadí"),
(BLACK, "černé pozadí"),
(YELLOW, "žluté pozadí"),
(GREEN, "zelené pozadí"),
)
STYLE_CSS = {
WHITE: "",
BLACK: "emphasized-black",
YELLOW: "emphasized-lemon",
GREEN: "emphasized-acidgreen",
}
RICH_TEXT_FEATURES = [
"h2",
"h3",
"h4",
"bold",
"italic",
"ul-elections2021",
"ol-elections2021",
"blockquote-elections2021",
"link",
"image",
"document-link",
]
### FIELDS
text = RichTextField("článek", blank=True, features=RICH_TEXT_FEATURES)
......@@ -132,7 +105,7 @@ class Elections2021ArticlePage(ArticleMixin, SubpageMixin, MetadataPageMixin, Pa
verbose_name = "Aktualita"
def card_css_class(self):
return self.STYLE_CSS[self.card_style]
return STYLE_CSS[self.card_style]
def get_context(self, request):
context = super().get_context(request)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment