Skip to content

Commit

Permalink
Merge branch 'main' into tile-map-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wpears committed Oct 15, 2024
2 parents b115619 + 596ba96 commit eaad1b1
Show file tree
Hide file tree
Showing 34 changed files with 1,093 additions and 201 deletions.
5 changes: 5 additions & 0 deletions .env_SAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,8 @@ export HUD_API_ENDPOINT=http://localhost:8000/hud-api-replace/
# export OIDC_OP_USER_ENDPOINT=http://localhost:8080/openid/userinfo
# export OIDC_OP_JWKS_ENDPOINT=[Not used for test OIDC provider]
# export OIDC_OP_ADMIN_ROLE=[Not supported by test OIDC provider]

###############################
# Deletion archival storage
###############################
# export WAGTAIL_DELETION_ARCHIVE_PATH=/path/to/write/deleted/content/json/files
23 changes: 21 additions & 2 deletions cfgov/cfgov/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"mozilla_django_oidc",
"draftail_icons",
"wagtail_footnotes",
"wagtail_deletion_archival",
)

MIDDLEWARE = (
Expand Down Expand Up @@ -270,7 +271,23 @@
"django.contrib.staticfiles.finders.FileSystemFinder",
]

STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"
STORAGES = {
"default": {
"BACKEND": "django.core.files.storage.FileSystemStorage",
},
"staticfiles": {
"BACKEND": "django.contrib.staticfiles.storage.StaticFilesStorage",
},
}

if WAGTAIL_DELETION_ARCHIVE_PATH := os.getenv("WAGTAIL_DELETION_ARCHIVE_PATH"):
STORAGES["wagtail_deletion_archival"] = {
"BACKEND": "django.core.files.storage.FileSystemStorage",
"OPTIONS": {
"location": WAGTAIL_DELETION_ARCHIVE_PATH,
}
}


# Add the frontend build output to static files.
STATICFILES_DIRS = [
Expand Down Expand Up @@ -362,12 +379,14 @@
if os.environ.get("S3_ENABLED", "False") == "True":
AWS_ACCESS_KEY_ID = os.environ["AWS_ACCESS_KEY_ID"]
AWS_SECRET_ACCESS_KEY = os.environ["AWS_SECRET_ACCESS_KEY"]
DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
AWS_S3_CUSTOM_DOMAIN = os.environ.get("AWS_S3_CUSTOM_DOMAIN")
MEDIA_URL = os.path.join(
AWS_STORAGE_BUCKET_NAME + ".s3.amazonaws.com", AWS_LOCATION, ""
)

STORAGES["default"] = {
"BACKEND": "storages.backends.s3boto3.S3Boto3Storage",
}

# GovDelivery
GOVDELIVERY_ACCOUNT_CODE = os.environ.get("GOVDELIVERY_ACCOUNT_CODE")
Expand Down
6 changes: 3 additions & 3 deletions cfgov/cfgov/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@
EMAIL_HOST = os.getenv("EMAIL_HOST")
DEFAULT_FROM_EMAIL = "[email protected]"

STATICFILES_STORAGE = (
"django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
)
STORAGES["staticfiles"] = {
"BACKEND": "django.contrib.staticfiles.storage.ManifestStaticFilesStorage"
}

STATIC_ROOT = os.environ["DJANGO_STATIC_ROOT"]

Expand Down
3 changes: 3 additions & 0 deletions cfgov/cfgov/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@

GOVDELIVERY_API = "core.govdelivery.MockGovDelivery"

# Disable Wagtail deletion archive storage during testing.
STORAGES.pop("wagtail_deletion_archival", None)

STATICFILES_FINDERS += [
"core.testutils.mock_staticfiles.MockStaticfilesFinder",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,19 @@
{% if effective_start_date and effective_end_date %}
{% set date_message = 'You are viewing a previous version of the FIG, effective ' + effective_start_date + ' to ' + effective_end_date + '.' %}
{% endif %}
{% set banner_modification = ' o-banner--dark' if version_status == 'Archived' else '' %}

{% block banner_top %}
{% if version_status %}
{% import 'v1/includes/molecules/notification.html' as notification with context %}
<div class="o-banner{{ banner_modification }}">
<div class="wrapper
wrapper--match-content">
{{ notification.render(
'warning',
true,
version_message,
date_message,
[ {
'text': 'View all versions of the FIG.',
'url': '../'
} ]
) }}
</div>
</div>
{% set is_banner_dark = true if version_status == 'Archived' else false %}
{% import 'v1/includes/molecules/banner.html' as banner %}
{{- banner.render(
is_banner_dark,
version_message,
date_message,
[ {
'text': 'View all versions of the FIG',
'url': '../'
} ]
) }}
{% endif %}
{% endblock %}

Expand Down
3 changes: 1 addition & 2 deletions cfgov/teachers_digital_platform/models/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ class ActivityPageHandoutDocuments(Orderable):
class ActivityPage(CFGOVPage):
"""A model for the Activity Detail page."""

# Allow Activity pages to exist under the ActivityIndexPage or the Trash
parent_page_types = ["ActivityIndexPage", "v1.HomePage"]
parent_page_types = ["ActivityIndexPage"]
subpage_types = []

date = models.DateField("Updated", default=timezone.now)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ def test_can_not_create_an_activity_page_under_home_page(self):
self.assertCanNotCreateAt(ActivityPage, HomePage)

def test_activity_page_parent_pages(self):
self.assertAllowedParentPageTypes(
ActivityPage, {ActivityIndexPage, HomePage}
)
self.assertAllowedParentPageTypes(ActivityPage, {ActivityIndexPage})

def test_can_create_activity_index_page(self):
root_page = HomePage.objects.first()
Expand Down
23 changes: 23 additions & 0 deletions cfgov/v1/jinja2/v1/blog/legacy_blog_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{% extends 'v1/blog/blog_page.html' %}

{% block content_intro scoped -%}
{% import 'v1/includes/molecules/banner.html' as banner %}
{% set canonical_archive_url = 'https://wayback.archive-it.org/23462/20241001120000/' ~ request.build_absolute_uri(request.path) | lower %}
{{- banner.render(
true,
'Archived content',
'This content has been archived, and its original formatting has been removed.',
[ {
'text': 'View this page as it was originally published',
'url': canonical_archive_url
} ]
) }}
{%- endblock %}

{% block content_main %}

{% include 'v1/includes/article.html' %}
{% block post_article_content %}

{% endblock %}
{% endblock %}
32 changes: 7 additions & 25 deletions cfgov/v1/jinja2/v1/events/_macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ <h2 class="event-venue__heading">
</div>
</div>
</div>
{% if event.venue_image != 'none'
or (event_state == 'past' and event.archive_video_id)
or (event_state == 'present' and event.live_video_id) %}
<footer>
<figure class="event-media__container">
{% if event_state == 'present' and event.live_video_id %}
Expand All @@ -128,27 +125,13 @@ <h2 class="event-venue__heading">
video_id=event.live_video_id,
button_pos='bottom-right'
) }}
{% elif event_state == 'past' %}
{% if event.archive_video_id %}
{# DISPLAY VIDEO RECORDING #}
{% import 'v1/includes/organisms/video-player.html' as video_player with context %}
{{ video_player.render(
video_id=event.archive_video_id,
button_pos='bottom-right'
) }}
{% elif event.post_event_image_type == 'image' %}
{# DISPLAY SPECIFICALLY-CHOSEN POST-EVENT IMAGE #}
{% set img = image(event.post_event_image, 'width-1416') %}
<img class="o-post-preview__image"
src="{{ img.url }}"
alt="{{ image_alt_value(img) }}">
{% else %}
{# DISPLAY PLACEHOLDER POST-EVENT IMAGE #}
{% set img = image(event.post_event_image, 'width-1416') %}
<img class="o-post-preview__image"
src="{{ static('img/cfpb_video_cover_card_1380x776.png') }}"
alt="">
{% endif %}
{% elif event_state == 'past' and event.archive_video_id %}
{# DISPLAY VIDEO RECORDING #}
{% import 'v1/includes/organisms/video-player.html' as video_player with context %}
{{ video_player.render(
video_id=event.archive_video_id,
button_pos='bottom-right'
) }}
{% elif event.venue_image_type == 'map' %}
{# DISPLAY MAP IMAGE #}
{# Note: Max dimesions for Mapbox static image API: 1280x1280. #}
Expand All @@ -162,7 +145,6 @@ <h2 class="event-venue__heading">
{% endif %}
</figure>
</footer>
{% endif %}
</section>
{% endmacro %}

Expand Down
42 changes: 42 additions & 0 deletions cfgov/v1/jinja2/v1/includes/molecules/banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{# ==========================================================================

banner.render()

==========================================================================

Description:

Builds banner markup when given:

is_dark: Whether the banner is dark or not. Default is false.

message: Text to display within the banner's notification markup.

explanation: Text to display as an explanation
within the banner's notification markup.
Defaults to none.

links: Array of link objects, which each contain:
- text (required): text of link.
- url: link url.
- is_link_boldface: sets bold formatting.
- open_link_in_new_window: opens the link in a new window
Defaults to an empty array.

========================================================================== #}

{% macro render(is_dark, message, explanation, links) %}
<div class="o-banner{{ ' o-banner--dark' if is_dark else '' }}">
<div class="wrapper wrapper--match-content">
{% import 'v1/includes/molecules/notification.html' as notification %}
{{ notification.render(
'warning',
true,
message,
explanation,
links
) }}
</div>
</div>
{% endmacro %}

19 changes: 7 additions & 12 deletions cfgov/v1/jinja2/v1/includes/organisms/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,17 @@
<header class="o-header{% if mega_menu_content %} o-header--mega-menu{% endif %}">

{% if flag_enabled('BETA_NOTICE') %}
{% import 'v1/includes/molecules/notification.html' as notification with context %}
<div class="o-banner">
<div class="wrapper
wrapper--match-content">
{{ notification.render(
'warning',
true,
'This beta site is a work in progress. Our regular site continues to be
<a href="https://www.consumerfinance.gov/">www.consumerfinance.gov</a>.' | safe
) }}
</div>
</div>
{% import 'v1/includes/molecules/banner.html' as banner %}
{{- banner.render(
false,
'This beta site is a work in progress. Our regular site continues to be
<a href="https://www.consumerfinance.gov/">www.consumerfinance.gov</a>.' | safe
) }}
{% endif %}

{% if banners %}
{% for banner in banners %}
{# TODO: Update this to use the banner.html template. #}
<div class="o-banner">
<div class="wrapper
wrapper--match-content">
Expand Down
20 changes: 20 additions & 0 deletions cfgov/v1/migrations/0038_emailsignup_disclaimer_page_set_null.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.14 on 2024-08-26 13:13

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


class Migration(migrations.Migration):

dependencies = [
('wagtailcore', '0093_uploadedfile'),
('v1', '0037_add_table_caption'),
]

operations = [
migrations.AlterField(
model_name='emailsignup',
name='disclaimer_page',
field=models.ForeignKey(blank=True, help_text='Choose the page that the "See Privacy Act statement" link should go to. If in doubt, use "Generic Email Sign-Up Privacy Act Statement".', null=True, on_delete=django.db.models.deletion.SET_NULL, to='wagtailcore.page', verbose_name='Privacy Act statement'),
),
]
21 changes: 21 additions & 0 deletions cfgov/v1/migrations/0039_remove_post_event_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.16 on 2024-10-15 14:48

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('v1', '0038_emailsignup_disclaimer_page_set_null'),
]

operations = [
migrations.RemoveField(
model_name='eventpage',
name='post_event_image',
),
migrations.RemoveField(
model_name='eventpage',
name='post_event_image_type',
),
]
2 changes: 1 addition & 1 deletion cfgov/v1/models/blog_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ class LegacyBlogPage(AbstractFilterPage):
edit_handler = AbstractFilterPage.generate_edit_handler(
content_panel=FieldPanel("content")
)
template = "v1/blog/blog_page.html"
template = "v1/blog/legacy_blog_page.html"
5 changes: 2 additions & 3 deletions cfgov/v1/models/filterable_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,8 @@ def get_search_class():
return FilterablePagesDocumentSearch

def get_filterable_search(self):
# If searching globally, use the root page of this page's Wagtail
# Site. If the page doesn't live under a Site (for example, it is
# in the Trash), use the default Site.
# If searching globally, use the root page of this page's Wagtail Site.
# If the page doesn't live under a Site, use the default Site.
if not self.filter_children_only:
site = self.get_site()

Expand Down
Loading

0 comments on commit eaad1b1

Please sign in to comment.