Skip to content

Commit

Permalink
Merge pull request #33 from hotosm/feat/working-groups-join-convo-pages
Browse files Browse the repository at this point in the history
working groups + join our conversation + 404 pages
  • Loading branch information
luminaryFlowers authored Jul 17, 2024
2 parents dfbb611 + ba06a01 commit 567323e
Show file tree
Hide file tree
Showing 28 changed files with 489 additions and 15 deletions.
11 changes: 10 additions & 1 deletion app/core/models.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Empty file added app/misc/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions app/misc/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions app/misc/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class MiscConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'app.misc'
32 changes: 32 additions & 0 deletions app/misc/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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',),
),
]
25 changes: 25 additions & 0 deletions app/misc/migrations/0002_joinourconversationpage.py
Original file line number Diff line number Diff line change
@@ -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',),
),
]
Original file line number Diff line number Diff line change
@@ -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'),
),
]
Original file line number Diff line number Diff line change
@@ -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),
),
]
Original file line number Diff line number Diff line change
@@ -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),
),
]
Empty file added app/misc/migrations/__init__.py
Empty file.
95 changes: 95 additions & 0 deletions app/misc/models.py
Original file line number Diff line number Diff line change
@@ -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'),
]
46 changes: 46 additions & 0 deletions app/misc/templates/misc/join_our_conversation_page.html
Original file line number Diff line number Diff line change
@@ -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 %}

<div class="max-w-7xl mx-auto my-10">
<div class="px-6 md:px-10">
{% include "ui/components/SectionHeadingWithUnderline.html" with title=page.get_connected_title %}
<div class="grid md:grid-cols-2 lg:grid-cols-3 gap-8 mt-6">
{% for block in page.get_connected_blocks %}
<div class="p-6 bg-hot-off-white">
{% image block.value.icon original class="h-8 w-8 mt-2" %}
<h1 class="text-h4 font-semibold mt-4">
{{block.value.title}}
</h1>
<div class="base-article-m">
{{block.value.description}}
</div>
</div>
{% endfor %}
</div>

<div class="text-black mt-20 [&_h1]:text-black [&_a]:text-black">
{% include "ui/components/dogear_boxes/DogearAnyColourLong.html" with colour="var(--hot-off-white)" title=page.code_of_conduct_title linktext=page.code_of_conduct_link_text linkurl=page.code_of_conduct_link_url %}
</div>

<div class="grid grid-cols-1 md:grid-cols-2 gap-8 text-white mt-10 mb-20">
<div>
{% include "ui/components/dogear_boxes/DogearRed.html" with title=page.red_box_title linktext=page.red_box_link_text linkurl=page.red_box_link_url %}
</div>
<div>
{% include "ui/components/dogear_boxes/DogearBlack.html" with title=page.black_box_title linktext=page.black_box_link_text linkurl=page.black_box_link_url %}
</div>
</div>
</div>
</div>
{% endblock %}
24 changes: 24 additions & 0 deletions app/misc/templates/misc/working_groups_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{% 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 %}

<div class="max-w-5xl mx-auto my-10">
<div class="px-6 md:px-10 grid gap-16">
{% for group in page.working_groups %}
<div>
{% include "ui/components/sections/LinkListSection.html" with title=group.value.title description=group.value.description links=group.value.links external_style=True %}
</div>
{% endfor %}
</div>
</div>
{% endblock %}
3 changes: 3 additions & 0 deletions app/misc/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions app/misc/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
2 changes: 1 addition & 1 deletion app/ui/templates/ui/components/BaseLink.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
this is optional, and defaults to the HOT red
{% endcomment %}

<a href="{{ linkurl }}">
<a href="{% include 'ui/components/PageOrLinkHrefText.html' %}">
<span class="border-b-hot-red border-b-2 pb-1 font-medium" {% if colour %}style="border-color: {{ colour }}"{% endif %}>{{ linktext }}</span>

<svg class="inline ml-4" {% if colour %}style="color: {{ colour }}"{% else %}style="color: var(--hot-red)"{% endif %} xmlns="http://www.w3.org/2000/svg" width="10.808" height="16.817" viewBox="0 0 10.808 16.817">
Expand Down
Loading

0 comments on commit 567323e

Please sign in to comment.