diff --git a/website/common/templatetags/footer_tags.py b/website/common/templatetags/footer_tags.py index 104ea7a..822fdfb 100644 --- a/website/common/templatetags/footer_tags.py +++ b/website/common/templatetags/footer_tags.py @@ -1,6 +1,6 @@ from django.template import Library -from website.contrib.singleton_url.utils import SingletonURLCache +from website.contrib.singleton_page.utils import SingletonPageCache from website.home.models import HomePage register = Library() @@ -9,5 +9,5 @@ register = Library() @register.inclusion_tag("common/footer.html") def footer() -> dict: return { - "homepage_url": SingletonURLCache.get_url(HomePage), + "homepage_url": SingletonPageCache.get_url(HomePage), } diff --git a/website/common/templatetags/navbar_tags.py b/website/common/templatetags/navbar_tags.py index dac5e42..ea09b32 100644 --- a/website/common/templatetags/navbar_tags.py +++ b/website/common/templatetags/navbar_tags.py @@ -1,6 +1,6 @@ from django.template import Library -from website.contrib.singleton_url.utils import SingletonURLCache +from website.contrib.singleton_page.utils import SingletonPageCache from website.home.models import HomePage from website.search.models import SearchPage @@ -17,5 +17,5 @@ def navbar() -> dict: .public() .filter(show_in_menus=True) .order_by("title"), - "search_page_url": SingletonURLCache.get_url(SearchPage), + "search_page_url": SingletonPageCache.get_url(SearchPage), } diff --git a/website/contrib/singleton_url/__init__.py b/website/contrib/singleton_page/__init__.py similarity index 100% rename from website/contrib/singleton_url/__init__.py rename to website/contrib/singleton_page/__init__.py diff --git a/website/contrib/singleton_url/tests.py b/website/contrib/singleton_page/tests.py similarity index 61% rename from website/contrib/singleton_url/tests.py rename to website/contrib/singleton_page/tests.py index 1c9e5ee..78af6e3 100644 --- a/website/contrib/singleton_url/tests.py +++ b/website/contrib/singleton_page/tests.py @@ -3,14 +3,14 @@ from django.test import TestCase from website.common.models import ContentPage from website.home.models import HomePage -from .utils import SingletonURLCache +from .utils import SingletonPageCache class SingletonURLTestCase(TestCase): def test_gets_url(self) -> None: with self.assertNumQueries(2): - self.assertEqual(SingletonURLCache.get_url(HomePage), "http://localhost/") + self.assertEqual(SingletonPageCache.get_url(HomePage), "http://localhost/") def test_missing_page(self) -> None: with self.assertNumQueries(1): - self.assertIsNone(SingletonURLCache.get_url(ContentPage)) + self.assertIsNone(SingletonPageCache.get_url(ContentPage)) diff --git a/website/contrib/singleton_url/utils.py b/website/contrib/singleton_page/utils.py similarity index 96% rename from website/contrib/singleton_url/utils.py rename to website/contrib/singleton_page/utils.py index 64fd034..78bf729 100644 --- a/website/contrib/singleton_url/utils.py +++ b/website/contrib/singleton_page/utils.py @@ -5,7 +5,7 @@ from django.http.request import HttpRequest from wagtail.models import Page -class SingletonURLCache: +class SingletonPageCache: @classmethod def get_url_cache_key(cls, model: Type[Page]) -> str: return f"singleton_url_{model.__name__}" diff --git a/website/contrib/singleton_url/wagtail_hooks.py b/website/contrib/singleton_page/wagtail_hooks.py similarity index 71% rename from website/contrib/singleton_url/wagtail_hooks.py rename to website/contrib/singleton_page/wagtail_hooks.py index 3906315..7fdabee 100644 --- a/website/contrib/singleton_url/wagtail_hooks.py +++ b/website/contrib/singleton_page/wagtail_hooks.py @@ -3,7 +3,7 @@ from wagtail import hooks from website.common.utils import get_page_models -from .utils import SingletonURLCache +from .utils import SingletonPageCache @hooks.register("after_move_page") @@ -12,5 +12,5 @@ def clear_singleton_url_cache(**kwargs: dict) -> None: Clear all page caches, in case a parent has moved """ cache.delete_many( - [SingletonURLCache.get_url_cache_key(model) for model in get_page_models()] + [SingletonPageCache.get_url_cache_key(model) for model in get_page_models()] ) diff --git a/website/home/models.py b/website/home/models.py index 08100ef..03a3370 100644 --- a/website/home/models.py +++ b/website/home/models.py @@ -6,7 +6,7 @@ from wagtail.images.models import Image from wagtailmetadata.models import WagtailImageMetadataMixin from website.common.models import BasePage -from website.contrib.singleton_url.utils import SingletonURLCache +from website.contrib.singleton_page.utils import SingletonPageCache class HomePage(BasePage, WagtailImageMetadataMixin): @@ -49,5 +49,5 @@ class HomePage(BasePage, WagtailImageMetadataMixin): .order_by("-date") .first() ) - context["search_page_url"] = SingletonURLCache.get_url(SearchPage) + context["search_page_url"] = SingletonPageCache.get_url(SearchPage) return context diff --git a/website/settings.py b/website/settings.py index b4a0973..d306e13 100644 --- a/website/settings.py +++ b/website/settings.py @@ -41,7 +41,7 @@ INSTALLED_APPS = [ "website.contrib.code_block", "website.contrib.mermaid_block", "website.contrib.unsplash", - "website.contrib.singleton_url", + "website.contrib.singleton_page", "wagtail.contrib.forms", "wagtail.contrib.redirects", "wagtail.contrib.modeladmin", diff --git a/website/well_known/views.py b/website/well_known/views.py index 8196cd1..0ecb91a 100644 --- a/website/well_known/views.py +++ b/website/well_known/views.py @@ -8,7 +8,7 @@ from django.views.decorators.cache import cache_page from django.views.generic import TemplateView from website.contact.models import ContactPage -from website.contrib.singleton_url.utils import SingletonURLCache +from website.contrib.singleton_page.utils import SingletonPageCache class SecurityView(TemplateView): @@ -24,7 +24,7 @@ class SecurityView(TemplateView): def get_context_data(self, **kwargs: dict) -> dict: context = super().get_context_data(**kwargs) context["security_txt"] = self.request.build_absolute_uri(self.request.path) - context["contact_page_url"] = SingletonURLCache.get_url(ContactPage) + context["contact_page_url"] = SingletonPageCache.get_url(ContactPage) context["expires"] = ( (timezone.now() + self.expires).replace(microsecond=0).isoformat() )