Skip to content

Commit

Permalink
Migrate VPN resource center to Wagtail (#14860)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgibson committed Oct 2, 2024
1 parent 74fa6a9 commit a2ab0e7
Show file tree
Hide file tree
Showing 20 changed files with 839 additions and 9 deletions.
45 changes: 45 additions & 0 deletions bedrock/cms/models/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

from django.conf import settings
from django.db import models
from django.shortcuts import redirect

from wagtail.admin.panels import FieldPanel
Expand Down Expand Up @@ -67,3 +68,47 @@ class SimpleRichTextPage(AbstractBedrockCMSPage):
# If not set, Wagtail will automatically choose a name for the template
# in the format `<app_label>/<model_name_in_snake_case>.html`
template = "cms/simple_rich_text_page.html"


class ArticleIndexPageBase(AbstractBedrockCMSPage):
sub_title = models.CharField(
max_length=255,
blank=True,
)

content_panels = AbstractBedrockCMSPage.content_panels + [
FieldPanel("sub_title"),
]

class Meta:
abstract = True


class ArticleDetailPageBase(AbstractBedrockCMSPage):
image = models.ForeignKey(
"cms.BedrockImage",
null=True,
blank=True,
on_delete=models.SET_NULL,
related_name="+",
)

desc = models.CharField(
max_length=500,
blank=True,
help_text="A short description used on index page.",
)

content = RichTextField(
blank=True,
features=settings.WAGTAIL_RICHTEXT_FEATURES_FULL,
)

content_panels = AbstractBedrockCMSPage.content_panels + [
FieldPanel("image"),
FieldPanel("desc"),
FieldPanel("content"),
]

class Meta:
abstract = True
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

# Generated by Django 4.2.16 on 2024-09-30 14:44

from django.db import migrations

import wagtail.blocks
import wagtail.fields
import wagtail.images.blocks


class Migration(migrations.Migration):
dependencies = [
("mozorg", "0003_leadershippage"),
]

operations = [
migrations.AlterField(
model_name="leadershippage",
name="leadership_sections",
field=wagtail.fields.StreamField(
[
(
"section",
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
blank=True,
help_text="Title for the section of the page e.g. 'Mozilla Corporation' or 'Mozilla Foundation.",
max_length=255,
null=True,
),
),
(
"leadership_group",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"title",
wagtail.blocks.CharBlock(
char_max_length=255,
help_text="Leadership group title, e.g. 'Executive Steering Committee' or 'Senior Leadership'.", # noqa E501
required=False,
),
),
(
"leaders",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"name",
wagtail.blocks.CharBlock(
char_max_length=255, placeholder="Enter the person's full name."
),
),
(
"headshot",
wagtail.blocks.StructBlock(
[
(
"image",
wagtail.images.blocks.ImageChooserBlock(
help_text="A headshot image of the person."
),
),
(
"image_alt_text",
wagtail.blocks.CharBlock(
char_max_length=255, help_text="Alt text for the headshot image."
),
),
(
"photos_link",
wagtail.blocks.URLBlock(
char_max_length=255,
help_text="External link to a .zip file of photos of the person.",
required=False,
),
),
]
),
),
("job_title", wagtail.blocks.CharBlock(char_max_length=255, required=False)),
(
"biography",
wagtail.blocks.RichTextBlock(
features=[
"h2",
"h3",
"hr",
"bold",
"italic",
"strikethrough",
"code",
"blockquote",
"link",
"ol",
"ul",
"image",
],
help_text="A biography limited to a few short paragraphs. Links and formatting are supported.", # noqa E501
required=False,
),
),
(
"external_links",
wagtail.blocks.ListBlock(
wagtail.blocks.StructBlock(
[
(
"url",
wagtail.blocks.URLBlock(
char_max_length=255,
help_text="Link to the person's website or social media account.", # noqa E501
required=False,
),
),
(
"type",
wagtail.blocks.ChoiceBlock(
choices=[
("url mastodon", "Mastodon"),
("url twitter", "Twitter"),
("url website", "Website"),
],
help_text="Selects a visual icon type for the link.",
required=False,
),
),
(
"text",
wagtail.blocks.CharBlock(
char_max_length=255,
help_text="Text to display for the link.",
required=False,
),
),
]
),
max_num=5,
min_num=0,
),
),
]
),
min_num=1,
),
),
]
),
min_num=1,
),
),
]
),
)
],
blank=True,
null=True,
),
),
]
3 changes: 2 additions & 1 deletion bedrock/mozorg/templates/mozorg/cms/about/leadership.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@

{% extends "base-protocol-mozilla.html" %}

{% block page_title_full %}{{ page.title }}{% endblock %}
{% block page_title_full %}{{ page.seo_title }}{% endblock %}
{% block page_desc %}{{ page.search_description }}{% endblock %}
{% block body_class %}{{ super() }} about-leadership{% endblock %}

{% block page_css %}
Expand Down
98 changes: 98 additions & 0 deletions bedrock/products/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.

# Generated by Django 4.2.16 on 2024-09-30 14:40

import django.db.models.deletion
from django.db import migrations, models

import wagtail.fields


class Migration(migrations.Migration):
initial = True

dependencies = [
("wagtailcore", "0093_uploadedfile"),
("cms", "0002_bedrockimage_bedrockrendition"),
]

operations = [
migrations.CreateModel(
name="VPNCallToActionSnippet",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("heading", models.CharField(max_length=255)),
(
"image",
models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="cms.bedrockimage"),
),
],
),
migrations.CreateModel(
name="VPNResourceCenterIndexPage",
fields=[
(
"page_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="wagtailcore.page",
),
),
("sub_title", models.CharField(blank=True, max_length=255)),
(
"call_to_action_bottom",
models.ForeignKey(
blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="products.vpncalltoactionsnippet"
),
),
(
"call_to_action_middle",
models.ForeignKey(
blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="products.vpncalltoactionsnippet"
),
),
],
options={
"abstract": False,
},
bases=("wagtailcore.page",),
),
migrations.CreateModel(
name="VPNResourceCenterDetailPage",
fields=[
(
"page_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
serialize=False,
to="wagtailcore.page",
),
),
("desc", models.CharField(blank=True, help_text="A short description used on index page.", max_length=500)),
("content", wagtail.fields.RichTextField(blank=True)),
(
"call_to_action_bottom",
models.ForeignKey(
blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="products.vpncalltoactionsnippet"
),
),
(
"image",
models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="cms.bedrockimage"),
),
],
options={
"abstract": False,
},
bases=("wagtailcore.page",),
),
]
3 changes: 3 additions & 0 deletions bedrock/products/migrations/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
Loading

0 comments on commit a2ab0e7

Please sign in to comment.