diff --git a/website/common/migrations/0005_remove_footersetting_site.py b/website/common/migrations/0005_remove_footersetting_site.py new file mode 100644 index 0000000..1f3eb48 --- /dev/null +++ b/website/common/migrations/0005_remove_footersetting_site.py @@ -0,0 +1,17 @@ +# Generated by Django 4.0.10 on 2023-04-16 14:06 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("common", "0004_alter_footersetting_icons"), + ] + + operations = [ + migrations.RemoveField( + model_name="footersetting", + name="site", + ), + ] diff --git a/website/common/models.py b/website/common/models.py index 90ae150..74ffe65 100644 --- a/website/common/models.py +++ b/website/common/models.py @@ -14,7 +14,7 @@ from django.utils.text import slugify from django.views.decorators.cache import cache_page from wagtail.admin.panels import FieldPanel, MultiFieldPanel from wagtail.contrib.routable_page.models import RoutablePageMixin, route -from wagtail.contrib.settings.models import BaseSetting, register_setting +from wagtail.contrib.settings.models import BaseGenericSetting, register_setting from wagtail.fields import RichTextField, StreamField from wagtail.images import get_image_model_string from wagtail.images.views.serve import generate_image_url @@ -264,7 +264,7 @@ class ReferralLink(models.Model, index.Indexed): @register_setting(icon="arrow-down") -class FooterSetting(BaseSetting): +class FooterSetting(BaseGenericSetting): icons = StreamField( [("icon", SnippetChooserBlock("contact.OnlineAccount", icon="user"))], use_json_field=True, diff --git a/website/common/templatetags/footer_tags.py b/website/common/templatetags/footer_tags.py index 8e1384a..a21d064 100644 --- a/website/common/templatetags/footer_tags.py +++ b/website/common/templatetags/footer_tags.py @@ -10,7 +10,7 @@ register = Library() @register.inclusion_tag("common/footer.html", takes_context=True) def footer(context: dict) -> dict: request = context["request"] - footer_setting = FooterSetting.for_request(request) + footer_setting = FooterSetting.load(request) return { "homepage_url": SingletonPageCache.get_url(HomePage, request), "online_accounts": [block.value for block in footer_setting.icons], diff --git a/website/common/tests/test_pages.py b/website/common/tests/test_pages.py index 0bad11b..a18e9f7 100644 --- a/website/common/tests/test_pages.py +++ b/website/common/tests/test_pages.py @@ -35,7 +35,7 @@ class ContentPageTestCase(TestCase): self.assertEqual(response.status_code, 200) def test_queries(self) -> None: - with self.assertNumQueries(40): + with self.assertNumQueries(38): self.client.get(self.page.url) @@ -52,7 +52,7 @@ class ListingPageTestCase(TestCase): ContentPageFactory(parent=cls.page) def test_accessible(self) -> None: - with self.assertNumQueries(44): + with self.assertNumQueries(42): response = self.client.get(self.page.url) self.assertEqual(response.status_code, 200) self.assertEqual(len(response.context["listing_pages"]), 2) diff --git a/website/common/tests/test_views.py b/website/common/tests/test_views.py index a6de697..a7c948e 100644 --- a/website/common/tests/test_views.py +++ b/website/common/tests/test_views.py @@ -22,7 +22,7 @@ class Error404PageTestCase(TestCase): ) def test_queries(self) -> None: - with self.assertNumQueries(27): + with self.assertNumQueries(25): self.client.get(self.url) diff --git a/website/search/tests.py b/website/search/tests.py index d9dab95..3ed11ab 100644 --- a/website/search/tests.py +++ b/website/search/tests.py @@ -89,7 +89,7 @@ class SearchPageResultsTestCase(TestCase): ) def test_too_high_page(self) -> None: - with self.assertNumQueries(52): + with self.assertNumQueries(50): response = self.client.get( self.url, {"q": "post", "page": 3}, HTTP_HX_REQUEST="true" )