Skip to content

Commit

Permalink
auto format with black and sort
Browse files Browse the repository at this point in the history
  • Loading branch information
goapunk authored and m4ra committed Jul 2, 2024
1 parent 9de62ed commit b1ac7b6
Show file tree
Hide file tree
Showing 140 changed files with 49,399 additions and 2,616 deletions.
2 changes: 1 addition & 1 deletion apps/academy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
default_app_config = 'apps.academy.apps.Config'
default_app_config = "apps.academy.apps.Config"
4 changes: 2 additions & 2 deletions apps/academy/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@


class AcademyConfig(AppConfig):
name = 'apps.academy'
label = 'academy'
name = "apps.academy"
label = "academy"
139 changes: 78 additions & 61 deletions apps/academy/blocks.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
from django.template.defaulttags import register
from wagtail.blocks import (CharBlock, ChoiceBlock, ListBlock,
PageChooserBlock, RichTextBlock, StructBlock,
TextBlock, URLBlock)
from wagtail.blocks import CharBlock
from wagtail.blocks import ChoiceBlock
from wagtail.blocks import ListBlock
from wagtail.blocks import PageChooserBlock
from wagtail.blocks import RichTextBlock
from wagtail.blocks import StructBlock
from wagtail.blocks import TextBlock
from wagtail.blocks import URLBlock
from wagtail.images.blocks import ImageChooserBlock

from apps.academy.choices import TOPIC_CHOICES
Expand All @@ -10,25 +15,34 @@
class ChallengeStepBlock(StructBlock):
challenge_step_title = CharBlock()
challenge_step_text = RichTextBlock(required=False)
links = ListBlock(StructBlock(
[
("challenge_step_academy_links", PageChooserBlock(
target_model='academy.AcademyPage',
required=False,
help_text='Add link to a challenge page either internal '
'or external'
)),
("challenge_step_external_links", PageChooserBlock(
target_model='academy.AcademyExternalLink',
required=False, ))
]
))
links = ListBlock(
StructBlock(
[
(
"challenge_step_academy_links",
PageChooserBlock(
target_model="academy.AcademyPage",
required=False,
help_text="Add link to a challenge page either internal "
"or external",
),
),
(
"challenge_step_external_links",
PageChooserBlock(
target_model="academy.AcademyExternalLink",
required=False,
),
),
]
)
)

class Meta:
template = 'academy/blocks/block_academy_challenge.html'
icon = 'grip'
label = 'Academy challenge step'
help_text = 'Select the pages to be included in this challenge step'
template = "academy/blocks/block_academy_challenge.html"
icon = "grip"
label = "Academy challenge step"
help_text = "Select the pages to be included in this challenge step"


class AcademySingleTeaserBlock(StructBlock):
Expand All @@ -37,63 +51,65 @@ class AcademySingleTeaserBlock(StructBlock):
body_text = TextBlock(required=True, max_length=164)
link = PageChooserBlock(
required=False,
help_text="Please only add either an internal or external link"
help_text="Please only add either an internal or external link",
)
external_link = URLBlock(
required=False,
label="External Link",
help_text="The external link overwrites the link to a local page."
help_text="The external link overwrites the link to a local page.",
)
link_text = CharBlock(required=True, max_length=24)
image = ImageChooserBlock(required=True)

class Meta:
template = 'academy/blocks/single_teaser_block.html'
icon = 'image'
label = 'Single teaser block'
template = "academy/blocks/single_teaser_block.html"
icon = "image"
label = "Single teaser block"


# sub block for AcademyCallToActionBlock
class CallToActionBlock(StructBlock):
headline = CharBlock(required=True, max_length=28)
image = ImageChooserBlock(
required=True,
help_text="Please add image with transparent background")
required=True, help_text="Please add image with transparent background"
)
body_text = TextBlock(required=True, max_length=120)
cta_link = StructBlock([
('internal_link', PageChooserBlock(required=False,
help_text="The external link "
"overwrites the link to a local "
"page. Please only add 1 link.")),
('external_link', URLBlock(required=False)),
])
link_text = CharBlock(
required=False, max_length=28, label='Link Text'
cta_link = StructBlock(
[
(
"internal_link",
PageChooserBlock(
required=False,
help_text="The external link "
"overwrites the link to a local "
"page. Please only add 1 link.",
),
),
("external_link", URLBlock(required=False)),
]
)
link_text = CharBlock(required=False, max_length=28, label="Link Text")
anchor_link = CharBlock(
required=False, max_length=28, label='Anchor Link',
help_text="Anchor link should be all one word."
required=False,
max_length=28,
label="Anchor Link",
help_text="Anchor link should be all one word.",
)


class AcademyCallToActionBlock(StructBlock):
columns = ListBlock(
CallToActionBlock(label='List and Image'),
max_num=2
)
columns = ListBlock(CallToActionBlock(label="List and Image"), max_num=2)

class Meta:
template = 'academy/blocks/block_col_cta.html'
icon = 'plus-inverse'
help_text = 'Add 1 or 2 column teaser with black '
'background and white writing'
template = "academy/blocks/block_col_cta.html"
icon = "plus-inverse"
help_text = "Add 1 or 2 column teaser with black "
"background and white writing"


class TopicBlock(StructBlock):
topic_category = ChoiceBlock(
choices=TOPIC_CHOICES,
required=True,
help_text='Select a topic'
choices=TOPIC_CHOICES, required=True, help_text="Select a topic"
)
topic_text = CharBlock(required=True, max_length=110)
topic_link_text = CharBlock(required=True, max_length=40)
Expand All @@ -103,19 +119,18 @@ class TopicBlockList(StructBlock):
title = CharBlock(required=True, max_length=74)
topics = ListBlock(TopicBlock(), min_num=3, max_num=3)
topic_url = PageChooserBlock(
required=True,
page_type='academy.AcademyIndexPage'
required=True, page_type="academy.AcademyIndexPage"
)

def get_context(self, value, parent_context=None):
context = super().get_context(value, parent_context=parent_context)
context['topics_dict'] = dict(TOPIC_CHOICES)
context["topics_dict"] = dict(TOPIC_CHOICES)
return context

class Meta:
template = 'academy/blocks/block_topic_teaser.html'
icon = 'grip'
label = '3 topic teasers'
template = "academy/blocks/block_topic_teaser.html"
icon = "grip"
label = "3 topic teasers"


@register.filter
Expand All @@ -126,9 +141,11 @@ def get_category_name(dict, key):
class AcademyTeaserColumnBlock(StructBlock):
link = PageChooserBlock(
required=True,
target_model=['academy.AcademyPage',
'academy.AcademyExternalLink',
'academy.AcademyChallengePage']
target_model=[
"academy.AcademyPage",
"academy.AcademyExternalLink",
"academy.AcademyChallengePage",
],
)


Expand All @@ -141,6 +158,6 @@ class AcademyTeaserColumnsListBlock(StructBlock):
)

class Meta:
template = 'academy/blocks/teaser_columns_block.html'
icon = 'list-ul'
label = 'Teaser columns block'
template = "academy/blocks/teaser_columns_block.html"
icon = "list-ul"
label = "Teaser columns block"
12 changes: 6 additions & 6 deletions apps/academy/choices.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.utils.translation import gettext_lazy as _

LIQDTHEORY = 'LT'
DIGITALCIVICSOCIETY = 'DS'
PARTICIPATIONACTION = 'PA'
LIQDTHEORY = "LT"
DIGITALCIVICSOCIETY = "DS"
PARTICIPATIONACTION = "PA"

TOPIC_CHOICES = [
(LIQDTHEORY, _('Liquid Democracy: Theory & Vision')),
(DIGITALCIVICSOCIETY, _('Digital Civic Society')),
(PARTICIPATIONACTION, _('Digital Participation In Action'))
(LIQDTHEORY, _("Liquid Democracy: Theory & Vision")),
(DIGITALCIVICSOCIETY, _("Digital Civic Society")),
(PARTICIPATIONACTION, _("Digital Participation In Action")),
]
Loading

0 comments on commit b1ac7b6

Please sign in to comment.