Skip to content

Commit

Permalink
Rename archival to wagtail_deletion_archival
Browse files Browse the repository at this point in the history
  • Loading branch information
willbarton committed Sep 23, 2024
1 parent 4da7f30 commit f1a6b3d
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .env_SAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,4 @@ export HUD_API_ENDPOINT=http://localhost:8000/hud-api-replace/
###############################
# Deletion archival storage
###############################
# export ARCHIVE_PATH=/path/to/write/deleted/content/json/files
# export WAGTAIL_DELETION_ARCHIVE_PATH=/path/to/write/deleted/content/json/files
13 changes: 0 additions & 13 deletions cfgov/archival/apps.py

This file was deleted.

8 changes: 4 additions & 4 deletions cfgov/cfgov/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"mozilla_django_oidc",
"draftail_icons",
"wagtail_footnotes",
"archival",
"wagtail_deletion_archival",
)

MIDDLEWARE = (
Expand Down Expand Up @@ -799,6 +799,6 @@
# 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.
ARCHIVE_PATH = os.environ.get("ARCHIVE_PATH")
if ARCHIVE_PATH is not None:
ARCHIVE_FILESYSTEM = f"osfs://{ARCHIVE_PATH}"
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}"
2 changes: 1 addition & 1 deletion cfgov/cfgov/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@

INSTALLED_APPS += ("tccp.tests.testapp",)

ARCHIVE_FILESYSTEM = "mem:///archive"
WAGTAIL_DELETION_ARCHIVE_FILESYSTEM = "mem:///archive"
File renamed without changes.
15 changes: 15 additions & 0 deletions cfgov/wagtail_deletion_archival/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.apps import AppConfig
from django.conf import settings

import fs


class WagtailDeletionArchivalConfig(AppConfig):
name = "wagtail_deletion_archival"
label = "wagtail_deletion_archival"
filesystem_name = getattr(
settings, "WAGTAIL_DELETION_ARCHIVE_FILESYSTEM", None
)
filesystem = (
fs.open_fs(filesystem_name) if filesystem_name is not None else None
)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

from wagtail.models import Site

from archival.utils import (
from v1.models import BlogPage
from wagtail_deletion_archival.utils import (
export_page,
get_last_migration,
import_page,
)
from v1.models import BlogPage


class LastMigrationTestCase(TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from wagtail.models import Site
from wagtail.test.utils import WagtailTestUtils

from archival.utils import export_page
from v1.models import BlogPage
from wagtail_deletion_archival.utils import export_page


class ExportViewTestCase(TestCase, WagtailTestUtils):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
from wagtail.models import Site
from wagtail.test.utils import WagtailTestUtils

from archival.wagtail_hooks import archive_page_data_receiver
from v1.models import BlogPage
from wagtail_deletion_archival.wagtail_hooks import archive_page_data_receiver


class ArchivePageOnDeletionTestCase(TestCase, WagtailTestUtils):
Expand All @@ -27,7 +27,7 @@ def setUp(self):
self.test_page3 = BlogPage(title="test page 3", slug="test-page3")
root_page.add_child(instance=self.test_page3)

self.fs = apps.get_app_config("archival").filesystem
self.fs = apps.get_app_config("wagtail_deletion_archival").filesystem

def test_delete_page(self):
self.client.post(
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_delete_page_confirmation(self):
0,
)

@override_settings(ARCHIVE_FILESYSTEM=None)
@override_settings(WAGTAIL_DELETION_ARCHIVE_FILESYSTEM=None)
def test_delete_page_with_no_archive_dir(self):
archive_page_data_receiver(None, self.test_page3)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from wagtail.models import Page

from archival.forms import ImportForm
from archival.utils import export_page, import_page
from wagtail_deletion_archival.forms import ImportForm
from wagtail_deletion_archival.utils import export_page, import_page


def export_view(request, page_id):
Expand Down Expand Up @@ -48,7 +48,7 @@ def import_view(request, page_id):

return TemplateResponse(
request,
"archival/import_page.html",
"wagtail_deletion_archival/import_page.html",
{
"parent_page": parent_page,
"form": input_form,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@

from fs import path as fs_path

from archival.utils import export_page
from archival.views import export_view, import_view
from wagtail_deletion_archival.utils import export_page
from wagtail_deletion_archival.views import export_view, import_view


def archive_page_data_receiver(sender, instance, **kwargs):
# If settings.ARCHIVE_FILESYSTEM is not set, don't do anything
if getattr(settings, "ARCHIVE_FILESYSTEM", None) is None:
# Skip all this if settings.WAGTAIL_DELETION_ARCHIVE_FILESYSTEM is not set
if getattr(settings, "WAGTAIL_DELETION_ARCHIVE_FILESYSTEM", None) is None:
return

fs = apps.get_app_config("archival").filesystem
fs = apps.get_app_config("wagtail_deletion_archival").filesystem

page = instance.specific
site = page.get_site()
Expand Down

0 comments on commit f1a6b3d

Please sign in to comment.