Skip to content

Commit

Permalink
NTI-work inclusion (#724)
Browse files Browse the repository at this point in the history
* NTI-work + Fehrm additions + flake8 enf

* Make manage.py executable

* Update src/involvement/locale/sv/LC_MESSAGES/django.po

Co-authored-by: Daniel Fehrm <daniel@fehrm.se>

* fix translations

* empty migration

* bring up to date

* fix migration conflic in involvment + add copy of footer info + quickfix of serverbreaking issue in branding/models.py

* access to manage.py

---------

Co-authored-by: Daniel Fehrm <daniel@fehrm.se>
Co-authored-by: Marmingen <melker.marminge@telia.com>
  • Loading branch information
3 people committed Mar 6, 2023
1 parent 888422d commit c52c1a6
Show file tree
Hide file tree
Showing 16 changed files with 360 additions and 130 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ coverage.xml
.pytest_cache/
cover/

# Translations
*.mo
*.pot
.pytest_cache/
cover/

# Translations
*.mo
*.pot
Expand Down Expand Up @@ -166,9 +172,9 @@ CACHE/
# VSCode
.vscode

# Docker data
# Docker data
postgres-data/

src/media/
*.log

23 changes: 21 additions & 2 deletions src/blocks/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.utils.translation import gettext_lazy as _
from django import forms
from wagtail.core import blocks
from wagtail.core.blocks.field_block import CharBlock, ChoiceBlock
from wagtail.images.blocks import ImageChooserBlock
from involvement.blocks import ContactCardBlock
from instagram.blocks import InstagramFeedChooserBlock
Expand Down Expand Up @@ -70,8 +71,26 @@ class Meta:


class HeadingBlock(blocks.StructBlock):
title = blocks.CharBlock(required=True)
subtitle = blocks.CharBlock(required=False)
title = CharBlock(required=True)
title_alignment = ChoiceBlock(
default=("Center", _("Center")),
required=True,
choices=[
("Left", _("Left")),
("Center", _("Center")),
("Right", _("Right"))],
help_text=_("Choose the title alignment")
)
subtitle = CharBlock(required=False)
subtitle_alignment = ChoiceBlock(
default=("Center", _("Center")),
required=True,
choices=[
("Left", _("Left")),
("Center", _("Center")),
("Right", _("Right"))],
help_text=_("Choose the subtitle alignment")
)

class Meta:
label = _('Heading')
Expand Down
12 changes: 10 additions & 2 deletions src/blocks/templates/blocks/title.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
<h2>{{ value.title }}</h2>
{% if value.subtitle %}<p>{{ value.subtitle }}</p>{% endif %}
<h2 style="text-align: {{ value.title_alignment }};">
{{ value.title }}
</h2>
{% if value.subtitle %}
<p {% if value.subtitle_alignment %}
style="text-align: {{ value.subtitle_alignment }};"
{% endif %}>
{{ value.subtitle }}
</p>
{% endif %}
25 changes: 25 additions & 0 deletions src/branding/migrations/0004_footer_sv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.2.3 on 2023-02-15 22:38

from django.db import migrations
import wagtail.core.blocks
import wagtail.core.fields


class Migration(migrations.Migration):

dependencies = [
('branding', '0003_footersettings'),
]

operations = [
migrations.RenameField(
model_name='footersettings',
old_name='footer',
new_name='footer_en',
),
migrations.AddField(
model_name='footersettings',
name='footer_sv',
field=wagtail.core.fields.StreamField([('column', wagtail.core.blocks.StructBlock([('size', wagtail.core.blocks.IntegerBlock(max_value=12, min_value=1)), ('content', wagtail.core.blocks.RichTextBlock())]))], blank=True),
),
]
21 changes: 21 additions & 0 deletions src/branding/migrations/0005_fix_empty_footer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 3.2.17 on 2023-03-01 18:25

from django.db import migrations
from django.db.models import F
from utils.data_migrations import stream_field_filter_map

# def del_footer_sv()


def copy_field(apps, schema):
MyModel = apps.get_model('branding', 'footersettings')
MyModel.objects.all().update(footer_sv=F('footer_en'))

class Migration(migrations.Migration):

dependencies = [
('branding', '0004_footer_sv'),
]

operations = [migrations.RunPython(copy_field),
]
30 changes: 25 additions & 5 deletions src/branding/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,49 @@

from django.utils.translation import gettext_lazy as _
from wagtail.admin.edit_handlers import FieldPanel, FieldRowPanel, \
MultiFieldPanel, StreamFieldPanel
MultiFieldPanel, StreamFieldPanel, TabbedInterface, ObjectList
from wagtail.core import blocks
from wagtail.core.fields import StreamField
from wagtail.images.edit_handlers import ImageChooserPanel
from utils.translation import TranslatedField


@register_setting(icon='fa-window-minimize')
class FooterSettings(BaseSetting):
class Meta:
verbose_name = _('footer')
verbose_name = _('footer_en') # quickfix

footer = StreamField(
footer_en = StreamField(
[('column', blocks.StructBlock([
('size', blocks.IntegerBlock(min_value=1, max_value=12)),
('content', blocks.RichTextBlock()),
]))],
blank=True,
)

panels = [
StreamFieldPanel('footer')
footer_sv = StreamField(
[('column', blocks.StructBlock([
('size', blocks.IntegerBlock(min_value=1, max_value=12)),
('content', blocks.RichTextBlock()),
]))],
blank=True,
)

footer = TranslatedField('footer_en', 'footer_sv')

panels_sv = [
StreamFieldPanel('footer_sv')
]

panels_en = [
StreamFieldPanel('footer_en')
]

edit_handler = TabbedInterface([
ObjectList(panels_en, heading=_("English")),
ObjectList(panels_sv, heading=_("Swedish"))
])


@register_setting(icon='openquote')
class SocialMediaSettings(BaseSetting):
Expand Down
29 changes: 29 additions & 0 deletions src/google/migrations/0030_auto_20230215_2336.py

Large diffs are not rendered by default.

61 changes: 61 additions & 0 deletions src/home/migrations/0055_auto_20230215_2336.py

Large diffs are not rendered by default.

Loading

0 comments on commit c52c1a6

Please sign in to comment.