diff --git a/app/core/models.py b/app/core/models.py index cc04e8e..9e66f7b 100644 --- a/app/core/models.py +++ b/app/core/models.py @@ -1,6 +1,7 @@ from django.db import models from wagtail.models import Page -from wagtail.fields import RichTextField +from wagtail.fields import StreamField +from wagtail.blocks import CharBlock, StreamBlock, StructBlock, URLBlock, RichTextBlock, PageChooserBlock from wagtail.snippets.models import register_snippet from wagtail.admin.panels import FieldPanel, MultiFieldPanel, InlinePanel @@ -29,3 +30,11 @@ def __str__(self): class Meta: verbose_name_plural = "Partners" + + +class LinkOrPageBlock(StreamBlock): + page = PageChooserBlock() + url = URLBlock() + + class Meta: + max_num = 1 diff --git a/app/misc/__init__.py b/app/misc/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/misc/admin.py b/app/misc/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/app/misc/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/app/misc/apps.py b/app/misc/apps.py new file mode 100644 index 0000000..39bf44d --- /dev/null +++ b/app/misc/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class MiscConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'app.misc' diff --git a/app/misc/migrations/0001_initial.py b/app/misc/migrations/0001_initial.py new file mode 100644 index 0000000..d0f060e --- /dev/null +++ b/app/misc/migrations/0001_initial.py @@ -0,0 +1,32 @@ +# Generated by Django 4.2.7 on 2024-07-17 18:08 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.blocks +import wagtail.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('wagtailcore', '0089_log_entry_data_json_null_to_object'), + ('wagtailimages', '0025_alter_image_file_alter_rendition_file'), + ] + + operations = [ + migrations.CreateModel( + name='WorkingGroupsPage', + 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')), + ('intro', wagtail.fields.RichTextField(blank=True, help_text='This is shown in the header.')), + ('working_groups', wagtail.fields.StreamField([('working_group', wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock()), ('description', wagtail.blocks.RichTextBlock()), ('links', wagtail.blocks.StreamBlock([('link', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock()), ('link', wagtail.blocks.URLBlock(required=False))]))]))]))], blank=True, null=True, use_json_field=True)), + ('header_image', models.ForeignKey(blank=True, help_text='Header image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/app/misc/migrations/0002_joinourconversationpage.py b/app/misc/migrations/0002_joinourconversationpage.py new file mode 100644 index 0000000..25dd2f0 --- /dev/null +++ b/app/misc/migrations/0002_joinourconversationpage.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.7 on 2024-07-17 22:31 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailcore', '0089_log_entry_data_json_null_to_object'), + ('misc', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='JoinOurConversationPage', + 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')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), + ), + ] diff --git a/app/misc/migrations/0003_joinourconversationpage_black_box_link_text_and_more.py b/app/misc/migrations/0003_joinourconversationpage_black_box_link_text_and_more.py new file mode 100644 index 0000000..f2d3c99 --- /dev/null +++ b/app/misc/migrations/0003_joinourconversationpage_black_box_link_text_and_more.py @@ -0,0 +1,68 @@ +# Generated by Django 4.2.7 on 2024-07-17 22:38 + +from django.db import migrations, models +import django.db.models.deletion +import wagtail.blocks +import wagtail.fields +import wagtail.images.blocks + + +class Migration(migrations.Migration): + + dependencies = [ + ('wagtailimages', '0025_alter_image_file_alter_rendition_file'), + ('misc', '0002_joinourconversationpage'), + ] + + operations = [ + migrations.AddField( + model_name='joinourconversationpage', + name='black_box_link_text', + field=models.CharField(default='Community Contact'), + ), + migrations.AddField( + model_name='joinourconversationpage', + name='black_box_title', + field=models.CharField(default='Contact a mapping community'), + ), + migrations.AddField( + model_name='joinourconversationpage', + name='code_of_conduct_link_text', + field=models.CharField(default='Code of Conduct'), + ), + migrations.AddField( + model_name='joinourconversationpage', + name='code_of_conduct_title', + field=models.CharField(default='Please read our Code of Conduct'), + ), + migrations.AddField( + model_name='joinourconversationpage', + name='get_connected_blocks', + field=wagtail.fields.StreamField([('blocks', wagtail.blocks.StructBlock([('icon', wagtail.images.blocks.ImageChooserBlock()), ('title', wagtail.blocks.CharBlock()), ('description', wagtail.blocks.RichTextBlock())]))], blank=True, help_text='Blocks to be shown under the Get Connected section.', null=True, use_json_field=True), + ), + migrations.AddField( + model_name='joinourconversationpage', + name='get_connected_title', + field=models.CharField(default='Get Connected!'), + ), + migrations.AddField( + model_name='joinourconversationpage', + name='header_image', + field=models.ForeignKey(blank=True, help_text='Header image', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.image'), + ), + migrations.AddField( + model_name='joinourconversationpage', + name='intro', + field=wagtail.fields.RichTextField(blank=True, help_text='This is shown in the header.'), + ), + migrations.AddField( + model_name='joinourconversationpage', + name='red_box_link_text', + field=models.CharField(default='Working Groups'), + ), + migrations.AddField( + model_name='joinourconversationpage', + name='red_box_title', + field=models.CharField(default='Join a working group'), + ), + ] diff --git a/app/misc/migrations/0004_joinourconversationpage_code_of_conduct_link_url.py b/app/misc/migrations/0004_joinourconversationpage_code_of_conduct_link_url.py new file mode 100644 index 0000000..1301422 --- /dev/null +++ b/app/misc/migrations/0004_joinourconversationpage_code_of_conduct_link_url.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2024-07-17 22:41 + +from django.db import migrations +import wagtail.blocks +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('misc', '0003_joinourconversationpage_black_box_link_text_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='joinourconversationpage', + name='code_of_conduct_link_url', + field=wagtail.fields.StreamField([('page', wagtail.blocks.PageChooserBlock()), ('url', wagtail.blocks.URLBlock())], blank=True, use_json_field=True), + ), + ] diff --git a/app/misc/migrations/0005_joinourconversationpage_black_box_link_url_and_more.py b/app/misc/migrations/0005_joinourconversationpage_black_box_link_url_and_more.py new file mode 100644 index 0000000..6ff83dc --- /dev/null +++ b/app/misc/migrations/0005_joinourconversationpage_black_box_link_url_and_more.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.7 on 2024-07-17 22:42 + +from django.db import migrations +import wagtail.blocks +import wagtail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('misc', '0004_joinourconversationpage_code_of_conduct_link_url'), + ] + + operations = [ + migrations.AddField( + model_name='joinourconversationpage', + name='black_box_link_url', + field=wagtail.fields.StreamField([('page', wagtail.blocks.PageChooserBlock()), ('url', wagtail.blocks.URLBlock())], blank=True, use_json_field=True), + ), + migrations.AddField( + model_name='joinourconversationpage', + name='red_box_link_url', + field=wagtail.fields.StreamField([('page', wagtail.blocks.PageChooserBlock()), ('url', wagtail.blocks.URLBlock())], blank=True, use_json_field=True), + ), + ] diff --git a/app/misc/migrations/__init__.py b/app/misc/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/misc/models.py b/app/misc/models.py new file mode 100644 index 0000000..b4b6bfa --- /dev/null +++ b/app/misc/models.py @@ -0,0 +1,95 @@ +from django.db import models + +from wagtail.admin.panels import FieldPanel, MultiFieldPanel +from wagtail.fields import RichTextField, StreamField +from wagtail.blocks import CharBlock, StreamBlock, StructBlock, URLBlock, RichTextBlock, PageChooserBlock +from wagtail.images.blocks import ImageChooserBlock +from wagtail.models import Page +from app.core.models import LinkOrPageBlock + + +class JoinOurConversationPage(Page): + max_count = 1 + + header_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Header image" + ) + intro = RichTextField(blank=True, help_text="This is shown in the header.") + + get_connected_title = models.CharField(default="Get Connected!") + get_connected_blocks = StreamField([ + ('blocks', StructBlock([ + ('icon', ImageChooserBlock()), + ('title', CharBlock()), + ('description', RichTextBlock()) + ])) + ], max_num=3, use_json_field=True, null=True, blank=True, help_text="Blocks to be shown under the Get Connected section.") + + code_of_conduct_title = models.CharField(default="Please read our Code of Conduct") + code_of_conduct_link_text = models.CharField(default="Code of Conduct") + code_of_conduct_link_url = StreamField(LinkOrPageBlock(), use_json_field=True, blank=True) + + red_box_title = models.CharField(default="Join a working group") + red_box_link_text = models.CharField(default="Working Groups") + red_box_link_url = StreamField(LinkOrPageBlock(), use_json_field=True, blank=True) + black_box_title = models.CharField(default="Contact a mapping community") + black_box_link_text = models.CharField(default="Community Contact") + black_box_link_url = StreamField(LinkOrPageBlock(), use_json_field=True, blank=True) + + content_panels = Page.content_panels + [ + FieldPanel('header_image'), + FieldPanel('intro'), + FieldPanel('get_connected_title'), + FieldPanel('get_connected_blocks'), + MultiFieldPanel([ + FieldPanel('code_of_conduct_title'), + FieldPanel('code_of_conduct_link_text'), + FieldPanel('code_of_conduct_link_url'), + ], heading="Code of Conduct"), + MultiFieldPanel([ + FieldPanel('red_box_title'), + FieldPanel('red_box_link_text'), + FieldPanel('red_box_link_url'), + FieldPanel('black_box_title'), + FieldPanel('black_box_link_text'), + FieldPanel('black_box_link_url'), + ], heading="Dogear Boxes"), + ] + + +class WorkingGroupLinkBlock(StructBlock): + text = CharBlock() + link = URLBlock(required=False) + + +class WorkingGroupBlock(StructBlock): + title = CharBlock() + description = RichTextBlock() + links = StreamBlock([('link', WorkingGroupLinkBlock())]) + + +class WorkingGroupsPage(Page): + max_count = 1 + + header_image = models.ForeignKey( + "wagtailimages.Image", + null=True, + blank=True, + on_delete=models.SET_NULL, + related_name="+", + help_text="Header image" + ) + intro = RichTextField(blank=True, help_text="This is shown in the header.") + + working_groups = StreamField([('working_group', WorkingGroupBlock())], use_json_field=True, null=True, blank=True) + + content_panels = Page.content_panels + [ + FieldPanel('header_image'), + FieldPanel('intro'), + FieldPanel('working_groups'), + ] diff --git a/app/misc/templates/misc/join_our_conversation_page.html b/app/misc/templates/misc/join_our_conversation_page.html new file mode 100644 index 0000000..dcd5031 --- /dev/null +++ b/app/misc/templates/misc/join_our_conversation_page.html @@ -0,0 +1,46 @@ +{% extends "base.html" %} +{% load static %} +{% load wagtailcore_tags %} +{% load wagtailimages_tags %} +{% load compress %} +{% block body_class %}template-workinggroupspage{% endblock %} +{% block extra_css %} + {% compress css %} + {% endcompress css %} +{% endblock extra_css %} + +{% block content %} + {% include "ui/components/PageHeaderWithBlur.html" with title=page.title subtitle=page.intro image=page.header_image %} + +
- {% include "ui/components/BaseLink.html" with linktext=link.value.text linkurl=link.value.link %} + {% if not external_style %} + {% include "ui/components/BaseLink.html" with linktext=link.value.text linkurl=link.value.link %} + {% else %} + + {{link.value.text}} + {% include "ui/components/icon_svgs/ExternalLinkIcon.html" with class="mb-1" %} + + {% endif %}
{% endfor %}{{home_page.e404_description}}
++ {% include "ui/components/BaseLink.html" with linktext=link.value.text linkurl=link.value.url %} +
+ {% endfor %} +