Skip to content

Commit

Permalink
Features for #288
Browse files Browse the repository at this point in the history
- Informatics settings now has a place for rich text that will appear in a banner at the top of every page
- Home page and site-section page content models now allow rich text and raw HTML blocks
  • Loading branch information
nutjob4life committed Oct 2, 2023
1 parent add52a3 commit 788f50b
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/edrn.theme/src/edrn/theme/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<body class='{% block body_class %}{% endblock body_class %}' onload='{% block body_onload %}{% endblock body_onload %}'>
{% wagtailuserbar %}
{% include 'includes/dev-warning.html' %}
{% include 'includes/site-wide-banner.html' %}
{% include 'includes/header.html' %}
{% include 'includes/breadcrumbs.html' %}
<main id='content' class='container pt-2' role='main'>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{# 🔮 TODO: caching #}
{% load wagtailcore_tags %}
{% if settings.edrnsitecontrols.Informatics.site_wide_banner %}
<div class='container py-3 px-3 mb-3 rounded shadow'>
<div class='row'>
<div class='col-auto'>
{{settings.edrnsitecontrols.Informatics.site_wide_banner|richtext}}
</div>
</div>
</div>
{% endif %}
{# -*- Django HTML -*- #}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.1.9 on 2023-10-02 18:23

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


class Migration(migrations.Migration):

dependencies = [
('edrnsitecontent', '0031_cdeexplorerobject_stewardship'),
]

operations = [
migrations.AlterField(
model_name='sectionpage',
name='body',
field=wagtail.fields.StreamField([('title', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock(help_text='Title to display', max_length=100, required=True))])), ('section_cards', wagtail.blocks.StructBlock([('cards', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(help_text='Title of this Site Section Card', max_length=200, required=True)), ('style', wagtail.blocks.ChoiceBlock(choices=[('aqua', 'Aqua'), ('cerulean', 'Cerulean'), ('teal', 'Teal'), ('cyan', 'Cyan'), ('navy', 'Navy')], help_text='Background style for this card', required=False)), ('image', wagtail.images.blocks.ImageChooserBlock(help_text='Little picture to show in the corner of the card', required=False)), ('page', wagtail.blocks.PageChooserBlock(help_text='Site page to which this card links, optional', required=False)), ('description', wagtail.blocks.RichTextBlock(features=['bold', 'italic', 'hr', 'link', 'document-link'], help_text='Short introductory text', required=False)), ('links', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('link_text', wagtail.blocks.CharBlock(help_text="Label for the link; don't use ‘here’", max_length=120, required=False)), ('internal_page', wagtail.blocks.PageChooserBlock(help_text='Page in the site to link to', required=False)), ('external_link', wagtail.blocks.URLBlock(help_text='External URL to link to', required=False)), ('view_name', wagtail.blocks.CharBlock(help_text='Name of a view to link to', max_length=32, required=False))])))])))])), ('raw_html', wagtail.blocks.RawHTMLBlock(help_text='Raw HTML (use with care)')), ('rich_text', wagtail.blocks.RichTextBlock(help_text='Richly formatted text', icon='doc-full', label='Rich Text'))], blank=True, null=True, use_json_field=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.1.9 on 2023-10-02 18:30

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


class Migration(migrations.Migration):

dependencies = [
('edrnsitecontent', '0032_alter_sectionpage_body'),
]

operations = [
migrations.AlterField(
model_name='homepage',
name='body',
field=wagtail.fields.StreamField([('title', wagtail.blocks.StructBlock([('text', wagtail.blocks.CharBlock(help_text='Title to display', max_length=100, required=True))])), ('section_cards', wagtail.blocks.StructBlock([('cards', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('title', wagtail.blocks.CharBlock(help_text='Title of this Site Section Card', max_length=200, required=True)), ('style', wagtail.blocks.ChoiceBlock(choices=[('aqua', 'Aqua'), ('cerulean', 'Cerulean'), ('teal', 'Teal'), ('cyan', 'Cyan'), ('navy', 'Navy')], help_text='Background style for this card', required=False)), ('image', wagtail.images.blocks.ImageChooserBlock(help_text='Little picture to show in the corner of the card', required=False)), ('page', wagtail.blocks.PageChooserBlock(help_text='Site page to which this card links, optional', required=False)), ('description', wagtail.blocks.RichTextBlock(features=['bold', 'italic', 'hr', 'link', 'document-link'], help_text='Short introductory text', required=False)), ('links', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('link_text', wagtail.blocks.CharBlock(help_text="Label for the link; don't use ‘here’", max_length=120, required=False)), ('internal_page', wagtail.blocks.PageChooserBlock(help_text='Page in the site to link to', required=False)), ('external_link', wagtail.blocks.URLBlock(help_text='External URL to link to', required=False)), ('view_name', wagtail.blocks.CharBlock(help_text='Name of a view to link to', max_length=32, required=False))])))])))])), ('carousel', wagtail.blocks.StructBlock([('media', wagtail.blocks.ListBlock(wagtail.blocks.StructBlock([('image', wagtail.images.blocks.ImageChooserBlock()), ('label', wagtail.blocks.CharBlock(help_text='Overlaid label, if any', max_length=120, required=False)), ('caption', wagtail.blocks.CharBlock(help_text='Overlaid caption, if any', max_length=400, required=False))])))])), ('raw_html', wagtail.blocks.RawHTMLBlock(help_text='Raw HTML (use with care)')), ('rich_text', wagtail.blocks.RichTextBlock(help_text='Richly formatted text', icon='doc-full', label='Rich Text'))], blank=True, null=True, use_json_field=True),
),
]
12 changes: 12 additions & 0 deletions src/edrnsite.content/src/edrnsite/content/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ class HomePage(MetadataPageMixin, Page):
('title', blocks.TitleBlock()),
('section_cards', blocks.SiteSectionCardsBlock()),
('carousel', blocks.CarouselBlock()),
('raw_html', wagtail_core_blocks.RawHTMLBlock(help_text='Raw HTML (use with care)')),
('rich_text', wagtail_core_blocks.RichTextBlock(
label='Rich Text',
icon='doc-full',
help_text='Richly formatted text',
)),
], null=True, blank=True, use_json_field=True)
content_panels = Page.content_panels + [FieldPanel('body')]
class Meta:
Expand All @@ -107,6 +113,12 @@ class SectionPage(MetadataPageMixin, Page):
body = StreamField([
('title', blocks.TitleBlock()),
('section_cards', blocks.SiteSectionCardsBlock()),
('raw_html', wagtail_core_blocks.RawHTMLBlock(help_text='Raw HTML (use with care)')),
('rich_text', wagtail_core_blocks.RichTextBlock(
label='Rich Text',
icon='doc-full',
help_text='Richly formatted text',
)),
], null=True, blank=True, use_json_field=True)
content_panels = Page.content_panels + [FieldPanel('body')]
class Meta:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.1.9 on 2023-10-02 17:32

from django.db import migrations
import wagtail.fields


class Migration(migrations.Migration):

dependencies = [
('edrnsitecontrols', '0003_informatics_funding_cycle'),
]

operations = [
migrations.AddField(
model_name='informatics',
name='site_wide_banner',
field=wagtail.fields.RichTextField(blank=True, help_text='Banner to display site-wide at the top of every page'),
),
]
3 changes: 3 additions & 0 deletions src/edrnsite.controls/src/edrnsite/controls/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.db import models
from wagtail.admin.panels import FieldPanel
from wagtail.contrib.settings.models import BaseSiteSetting, register_setting
from wagtail.fields import RichTextField
from wagtail.snippets.models import register_snippet


Expand Down Expand Up @@ -69,13 +70,15 @@ class Informatics(BaseSiteSetting):
null=False, help_text='URL to the DMCC "secure" site', blank=False
)
funding_cycle = models.CharField(default='Ⅴ', max_length=8, null=False, blank=False, help_text='EDRN Funding Cycle')
site_wide_banner = RichTextField(blank=True, help_text='Banner to display site-wide at the top of every page')
panels = [
FieldPanel('in_development'),
FieldPanel('entrez_email'),
FieldPanel('entrez_id'),
FieldPanel('entrez_api_key'),
FieldPanel('dmcc_url'),
FieldPanel('funding_cycle'),
FieldPanel('site_wide_banner'),
]


Expand Down

0 comments on commit 788f50b

Please sign in to comment.