-
Notifications
You must be signed in to change notification settings - Fork 112
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
Trashless Wagtail #8310
Open
willbarton
wants to merge
19
commits into
main
Choose a base branch
from
experiment/bakery-export
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Trashless Wagtail #8310
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
bd8b88a
Restore deletion
willbarton 26f12b0
Prevent deletion of locked pages
willbarton 31ffced
Write out JSON archives on deletion
willbarton b8beb56
Make EmailSignUp disclaimer_page null on deletion
willbarton 3d39222
Update comments
willbarton cb2e432
Use ARCHIVE_PATH as the env var
willbarton 782ac78
Add Apache configuration to serve archive path
willbarton 5be8efa
Remove unused type hint import
willbarton f2a5e04
Remove migration gating
willbarton 5a96d45
Use `page.relative_url`
willbarton e79f489
Remove unnecessary logging
willbarton d1405a0
Fix relative_url call
willbarton acf5d3c
Provide the user with an error if import fails
willbarton 687372f
Rename archival to wagtail_deletion_archival
willbarton 41e462f
Renumber v1 migration
chosak 1b8aa6c
Use Django storage for Wagtail deletion archive
chosak 957a3fb
Add tests, and a few minor fixups
chosak a9a1c09
Fix production staticfiles storage
chosak 2b935c3
Merge pull request #8599 from cfpb/wagtail-deletion-archive-storage
chosak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -118,6 +118,7 @@ | |||||||||||||||||
"mozilla_django_oidc", | ||||||||||||||||||
"draftail_icons", | ||||||||||||||||||
"wagtail_footnotes", | ||||||||||||||||||
"wagtail_deletion_archival", | ||||||||||||||||||
) | ||||||||||||||||||
|
||||||||||||||||||
MIDDLEWARE = ( | ||||||||||||||||||
|
@@ -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 = [ | ||||||||||||||||||
|
@@ -362,12 +379,15 @@ | |||||||||||||||||
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") | ||||||||||||||||||
|
@@ -793,3 +813,11 @@ | |||||||||||||||||
# Now we do some role/group-mapping for admins and regular users | ||||||||||||||||||
# Upstream "role" for users who get is_superuser | ||||||||||||||||||
OIDC_OP_ADMIN_ROLE = os.environ.get("OIDC_OP_ADMIN_ROLE") | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
# Deletion archive | ||||||||||||||||||
# If this is set then when Wagtail pages are deleted a JSON archive file will | ||||||||||||||||||
# be written to this path containing the deleted page's data. | ||||||||||||||||||
WAGTAIL_DELETION_ARCHIVE_PATH = os.environ.get("WAGTAIL_DELETION_ARCHIVE_PATH") | ||||||||||||||||||
if WAGTAIL_DELETION_ARCHIVE_PATH is not None: | ||||||||||||||||||
WAGTAIL_DELETION_ARCHIVE_FILESYSTEM = f"osfs://{WAGTAIL_DELETION_ARCHIVE_PATH}" | ||||||||||||||||||
Comment on lines
+816
to
+823
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I missed deleting this in my PR. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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", | ||||||
] | ||||||
|
@@ -71,3 +74,5 @@ | |||||
DEPLOY_ENVIRONMENT = "test" | ||||||
|
||||||
INSTALLED_APPS += ("tccp.tests.testapp",) | ||||||
|
||||||
WAGTAIL_DELETION_ARCHIVE_FILESYSTEM = "mem:///archive" | ||||||
Comment on lines
+77
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This can also be deleted. |
20 changes: 20 additions & 0 deletions
20
cfgov/v1/migrations/0038_emailsignup_disclaimer_page_set_null.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class WagtailDeletionArchivalConfig(AppConfig): | ||
name = "wagtail_deletion_archival" | ||
label = "wagtail_deletion_archival" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django import forms | ||
|
||
|
||
class ImportForm(forms.Form): | ||
page_file = forms.FileField(label="Page file", required=True) |
29 changes: 29 additions & 0 deletions
29
cfgov/wagtail_deletion_archival/templates/wagtail_deletion_archival/import_page.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{% extends "wagtailadmin/base.html" %} | ||
{% load i18n wagtailadmin_tags %} | ||
{% block titletag %}Import page into {{ parent_page.get_admin_display_title }}{% endblock %} | ||
|
||
{% block content %} | ||
{% include "wagtailadmin/shared/header.html" with title="Import page" subtitle=parent_page.get_admin_display_title icon="doc-empty-inverse" %} | ||
|
||
<div class="nice-padding"> | ||
{% include "wagtailadmin/shared/non_field_errors.html" %} | ||
|
||
<form enctype="multipart/form-data" action="{% url 'wagtail_deletion_archive_import' parent_page.id %}" method="POST"> | ||
{% csrf_token %} | ||
<ul class="fields"> | ||
{% for field in form %} | ||
<li> | ||
{% if field.is_hidden %} | ||
{{ field }} | ||
{% else %} | ||
{% include "wagtailadmin/shared/field.html" with field=field %} | ||
{% endif %} | ||
</li> | ||
{% endfor %} | ||
<li> | ||
<button type="submit" class="button button-longrunning" data-clicked-text="{% trans 'Uploading…' %}">{% icon name="spinner" %}<em>{% trans 'Upload' %}</em></button> | ||
</li> | ||
</ul> | ||
</form> | ||
</div> | ||
{% endblock %} |
Empty file.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.