Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Information Page #21

Open
wants to merge 42 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2dfa81d
Standard_pages app creation
nehakerung Nov 1, 2024
7c35050
Addition of InformationPage class in models
nehakerung Nov 4, 2024
93bb753
Changes to InformationPage class models
nehakerung Nov 4, 2024
5d4ec7d
Front end creation
nehakerung Nov 4, 2024
ddcaee6
Addition of template location and minor changes on information_page t…
nehakerung Nov 4, 2024
72d7fda
Added cms.standard_pages to installed_apps
nehakerung Nov 5, 2024
4e6cb4f
Updated apps.py for standard_pages to be similar to pre-existing apps
nehakerung Nov 5, 2024
0ba0955
Modified InformationPage in models
nehakerung Nov 5, 2024
afc6363
Updated template for informationPage
nehakerung Nov 5, 2024
de7c9bb
Modified models for standard_pages
nehakerung Nov 5, 2024
4a0a36b
Modified front end
nehakerung Nov 6, 2024
b1f8eda
working branch
nehakerung Nov 7, 2024
41d8bd2
Django models for information page updated and the template for the i…
sanjeevz3009 Nov 7, 2024
29af196
Zombie code removed
sanjeevz3009 Nov 7, 2024
ea31520
Unnused files deleted
sanjeevz3009 Nov 7, 2024
93e22b8
Mirgation file formatted
sanjeevz3009 Nov 7, 2024
524836e
django-manager-missing ignore added
sanjeevz3009 Nov 7, 2024
47316d4
TODO comment removed and docstrings added
sanjeevz3009 Nov 7, 2024
7f0ae06
Merge branch 'main' into feature/information-page-CMS-179
sanjeevz3009 Nov 7, 2024
5d7f29b
Information code formatted
sanjeevz3009 Nov 7, 2024
53627ec
Docstring rewritten to make it more concise
sanjeevz3009 Nov 7, 2024
b6af965
Updated body to content
sanjeevz3009 Nov 7, 2024
22cd8da
Conditional for last_updated added, InformationPage class docstring s…
sanjeevz3009 Nov 8, 2024
2a393b1
summary TextField null=true removed and the migration file regenerate…
sanjeevz3009 Nov 8, 2024
963591f
Removing the conditional as per requirement the summary field is requ…
sanjeevz3009 Nov 8, 2024
acb7074
InformationPage restrictions added
sanjeevz3009 Nov 8, 2024
cd3b04e
Merge branch 'main' into feature/information-page-CMS-179
sanjeevz3009 Nov 8, 2024
df367b3
Code formatted
sanjeevz3009 Nov 8, 2024
f15d658
Comments added
sanjeevz3009 Nov 11, 2024
ea81496
Moved parent_page code
nehakerung Nov 11, 2024
46d3c06
Removed extra blank lines for lint.py
nehakerung Nov 11, 2024
e2f8c22
Merge branch 'main' into feature/information-page-CMS-179
sanjeevz3009 Nov 11, 2024
b1bbaf2
Custom CSS added to make video embeds responsive
sanjeevz3009 Nov 11, 2024
784b06c
Formatting fixed
sanjeevz3009 Nov 11, 2024
697b141
Ignore Unexpected property "left" property-disallowed-list rule
sanjeevz3009 Nov 12, 2024
68e93f5
cms/release_calendar/models.py formating fixed
sanjeevz3009 Nov 12, 2024
e9d2f93
Merge branch 'main' into feature/information-page-CMS-179
nehakerung Nov 14, 2024
5f3b26a
Addition of equation partials
nehakerung Nov 14, 2024
c6edd94
Deleted media files and made lint, format test pass
nehakerung Nov 14, 2024
6bacf44
Repeated code remove, /media added to .gitignore, media file removed
nehakerung Nov 15, 2024
21e1533
Check tests pass
nehakerung Nov 15, 2024
af079e7
Custom sign commit
nehakerung Nov 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cms/core/tests/test_context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

class ContextProcessorTestCase(TestCase):
"""Tests for context processors."""

def setUp(self):
request_factory = RequestFactory()

Expand Down
1 change: 1 addition & 0 deletions cms/core/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

class CSRFTestCase(TestCase):
"""Tests for CSRF enforcement."""

def setUp(self):
# Client is created with each test to avoid mutation side-effects
self.client = Client(enforce_csrf_checks=True)
Expand Down
27 changes: 27 additions & 0 deletions cms/jinja2/templates/pages/information_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "templates/base_page.html" %}
{% from "components/related-content/_macro.njk" import onsRelatedContent %}

{% block main %}
<p>{{ page.summary }}</p>

{% if page.last_updated %}
<h5>Last Updated: {{ page.last_updated }}</h5>
{% endif %}

{% include_block page.content %}

{% if related_pages %}
{# fmt:off #}
{{-
onsRelatedContent({
"ariaLabel": _('Related content'),
"rows": [{
"id": 'related-content',
"title": _('Related content'),
"itemsList": related_pages
}]
})
-}}
{# fmt:on #}
{% endif %}
{% endblock %}
43 changes: 33 additions & 10 deletions cms/release_calendar/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,26 @@ class ReleaseCalendarPage(BasePage): # type: ignore[django-manager-missing]
subpage_types: ClassVar[list[str]] = []

# Fields
status = models.CharField(choices=ReleaseStatus.choices, default=ReleaseStatus.PROVISIONAL, max_length=32)
status = models.CharField(
choices=ReleaseStatus.choices, default=ReleaseStatus.PROVISIONAL, max_length=32
)
summary = RichTextField(features=settings.RICH_TEXT_BASIC)

release_date = models.DateTimeField(
blank=True, null=True, help_text=_("Required once the release has been confirmed.")
blank=True,
null=True,
help_text=_("Required once the release has been confirmed."),
MebinAbraham marked this conversation as resolved.
Show resolved Hide resolved
)
release_date_text = models.CharField(
max_length=50, blank=True, help_text=_("Format: 'Month YYYY', or 'Month YYYY to Month YYYY'.")
max_length=50,
blank=True,
help_text=_("Format: 'Month YYYY', or 'Month YYYY to Month YYYY'."),
)
next_release_date = models.DateTimeField(blank=True, null=True)
next_release_text = models.CharField(
max_length=255, blank=True, help_text=_("Formats: 'DD Month YYYY Time' or 'To be confirmed'.")
max_length=255,
blank=True,
help_text=_("Formats: 'DD Month YYYY Time' or 'To be confirmed'."),
)

notice = RichTextField(
Expand Down Expand Up @@ -88,15 +96,19 @@ class ReleaseCalendarPage(BasePage): # type: ignore[django-manager-missing]
is_census = models.BooleanField(
_("Census"),
default=False,
help_text=_("If ticked, will display an information block about the data being related to the Census."),
help_text=_(
"If ticked, will display an information block about the data being related to the Census."
),
)

changes_to_release_date = StreamField(
ReleaseCalendarChangesStoryBlock(),
blank=True,
help_text=_("Required if making changes to confirmed release dates."),
)
pre_release_access = StreamField(ReleaseCalendarPreReleaseAccessStoryBlock(), blank=True)
pre_release_access = StreamField(
ReleaseCalendarPreReleaseAccessStoryBlock(), blank=True
)
related_links = StreamField(ReleaseCalendarRelatedLinksStoryBlock(), blank=True)

content_panels: ClassVar[list[FieldPanel]] = [
Expand All @@ -107,14 +119,18 @@ class ReleaseCalendarPage(BasePage): # type: ignore[django-manager-missing]
FieldRowPanel(
[
FieldPanel("release_date"),
FieldPanel("release_date_text", heading=_("Or, release date text")),
FieldPanel(
"release_date_text", heading=_("Or, release date text")
),
],
heading="",
),
FieldRowPanel(
[
FieldPanel("next_release_date"),
FieldPanel("next_release_text", heading=_("Or, next release text")),
FieldPanel(
"next_release_text", heading=_("Or, next release text")
),
],
heading="",
),
Expand Down Expand Up @@ -169,7 +185,12 @@ def table_of_contents(self) -> list[dict[str, str | object]]:
items += block.block.to_table_of_contents_items(block.value)

if self.status in NON_PROVISIONAL_STATUSES and self.changes_to_release_date:
items += [{"url": "#changes-to-release-date", "text": _("Changes to this release date")}]
items += [
{
"url": "#changes-to-release-date",
"text": _("Changes to this release date"),
}
]

if self.status == ReleaseStatus.PUBLISHED and self.contact_details_id:
text = _("Contact details")
Expand All @@ -185,6 +206,8 @@ def table_of_contents(self) -> list[dict[str, str | object]]:
items += [{"url": f"#{slugify(text)}", "text": text}]

if self.related_links:
items += [{"url": "#links", "text": _("You might also be interested in")}]
items += [
{"url": "#links", "text": _("You might also be interested in")}
]

return items
1 change: 1 addition & 0 deletions cms/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"cms.images",
"cms.release_calendar",
"cms.users",
"cms.standard_pages",
"wagtail.embeds",
"wagtail.sites",
"wagtail.users",
Expand Down
Empty file.
8 changes: 8 additions & 0 deletions cms/standard_pages/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.apps import AppConfig


class StandardPagesConfig(AppConfig):
"""The standard_pages app config."""

default_auto_field = "django.db.models.BigAutoField"
name = "cms.standard_pages"
64 changes: 64 additions & 0 deletions cms/standard_pages/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Generated by Django 5.1.2 on 2024-11-08 15:48

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

import cms.core.fields


class Migration(migrations.Migration):
initial = True

dependencies = [
("images", "0001_initial"),
("wagtailcore", "0094_alter_page_locale"),
]

operations = [
migrations.CreateModel(
name="InformationPage",
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",
),
),
("listing_title", models.CharField(blank=True, max_length=255)),
("listing_summary", models.CharField(blank=True, max_length=255)),
("social_text", models.CharField(blank=True, max_length=255)),
("summary", models.TextField(max_length=255)),
("last_updated", models.DateField(blank=True, null=True)),
("content", cms.core.fields.StreamField(block_lookup={})),
(
"listing_image",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="images.customimage",
),
),
(
"social_image",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="images.customimage",
),
),
],
options={
"abstract": False,
},
bases=("wagtailcore.page", models.Model),
),
]
Empty file.
39 changes: 39 additions & 0 deletions cms/standard_pages/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from typing import ClassVar

from django.db import models
from wagtail.admin.panels import FieldPanel
from wagtail.search import index

from cms.core.blocks.stream_blocks import CoreStoryBlock
from cms.core.fields import StreamField
from cms.core.models import BasePage


class InformationPage(BasePage): # type: ignore[django-manager-missing]
MebinAbraham marked this conversation as resolved.
Show resolved Hide resolved
"""A generic information page model."""

template = "templates/pages/information_page.html"

parent_page_types: ClassVar[list[str]] = [
# Ensures that the information page can only be created under the home page
"home.HomePage",
# Ensures that the information page can be created under another information page
"standard_pages.InformationPage",
]

summary = models.TextField(max_length=255)
last_updated = models.DateField(blank=True, null=True)
content = StreamField(CoreStoryBlock())
MebinAbraham marked this conversation as resolved.
Show resolved Hide resolved

content_panels: ClassVar[list[FieldPanel]] = [
*BasePage.content_panels,
FieldPanel("summary"),
FieldPanel("last_updated"),
FieldPanel("content"),
]

search_fields: ClassVar[list[index.SearchField | index.AutocompleteField]] = [
*BasePage.search_fields,
index.SearchField("summary"),
index.SearchField("content"),
]
zerolab marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions cms/static_src/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,18 @@
body {
display: block;
}

// Custom CSS from Wagtail doc to enable responsive video embeds
.responsive-object {
position: relative;
}

.responsive-object iframe,
.responsive-object object,
.responsive-object embed {
position: absolute;
top: 0;
left: 0;
zerolab marked this conversation as resolved.
Show resolved Hide resolved
width: 100%;
height: 100%;
}
MebinAbraham marked this conversation as resolved.
Show resolved Hide resolved
Loading