Change footer settings to generic setting

This commit is contained in:
Jake Howard 2023-04-16 15:18:21 +01:00
parent 8b37b87a92
commit 6342726d7c
Signed by: jake
GPG key ID: 57AFB45680EDD477
6 changed files with 24 additions and 7 deletions

View file

@ -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",
),
]

View file

@ -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,

View file

@ -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],

View file

@ -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)

View file

@ -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)

View file

@ -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"
)