Skip to content

Commit 0772c15

Browse files
committed
Lint
1 parent db4a7d4 commit 0772c15

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

tbx/blog/models.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ def blog_posts(self):
5353
)
5454
# Get list of blog pages that are descendants of this page
5555
blog_posts = (
56-
BlogPage.objects.public().live()
56+
BlogPage.objects.public()
57+
.live()
5758
.descendant_of(self)
5859
.distinct()
5960
.prefetch_related(

tbx/blog/tests/test_models.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
from django.core.paginator import Page as PaginatorPage
2-
from faker import Faker
3-
from wagtail.coreutils import get_dummy_request
4-
from wagtail.models import PageViewRestriction
52

3+
from faker import Faker
64
from tbx.blog.factories import BlogIndexPageFactory, BlogPageFactory
75
from tbx.blog.models import BlogPage
86
from tbx.taxonomy.factories import SectorFactory, ServiceFactory
7+
from wagtail.coreutils import get_dummy_request
8+
from wagtail.models import PageViewRestriction
99
from wagtail.test.utils import WagtailPageTestCase
1010

1111
fake = Faker(["en_GB"])
@@ -16,11 +16,17 @@ class TestBlogIndexPageFactory(WagtailPageTestCase):
1616
def setUpTestData(cls):
1717
cls.blog_index = BlogIndexPageFactory(title="The Torchbox Blog")
1818
cls.blog_post = BlogPageFactory(title="The blog post", parent=cls.blog_index)
19-
cls.private_blog_post = BlogPageFactory(title="Private blog post", parent=cls.blog_index)
20-
cls.draft_blog_post = BlogPageFactory(title="Draft blog post", live=False, parent=cls.blog_index)
19+
cls.private_blog_post = BlogPageFactory(
20+
title="Private blog post", parent=cls.blog_index
21+
)
22+
cls.draft_blog_post = BlogPageFactory(
23+
title="Draft blog post", live=False, parent=cls.blog_index
24+
)
2125

2226
PageViewRestriction.objects.create(
23-
page=cls.private_blog_post, restriction_type="password", password="password123"
27+
page=cls.private_blog_post,
28+
restriction_type="password",
29+
password="password123",
2430
)
2531

2632
def test_get_context(self):
@@ -34,7 +40,9 @@ def test_blog_posts_property(self):
3440
another_blog = BlogPageFactory(title="Tech blog")
3541
BlogPageFactory(title="Tech blog", parent=another_blog)
3642

37-
self.assertQuerysetEqual(self.blog_index.blog_posts, BlogPage.objects.filter(pk=self.blog_post.pk))
43+
self.assertQuerysetEqual(
44+
self.blog_index.blog_posts, BlogPage.objects.filter(pk=self.blog_post.pk)
45+
)
3846

3947

4048
class TestBlogPageFactory(WagtailPageTestCase):

tbx/core/templatetags/torchbox_tags.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ def get_prev_sibling_by_order(page):
3737
@register.simple_tag
3838
def get_next_sibling_blog(page):
3939
sibling = (
40-
BlogPage.objects.filter(date__lt=page.date).order_by("-date").live().public().first()
40+
BlogPage.objects.filter(date__lt=page.date)
41+
.order_by("-date")
42+
.live()
43+
.public()
44+
.first()
4145
)
4246
if sibling:
4347
return sibling.specific
@@ -46,7 +50,11 @@ def get_next_sibling_blog(page):
4650
@register.simple_tag
4751
def get_prev_sibling_blog(page):
4852
sibling = (
49-
BlogPage.objects.filter(date__gt=page.date).order_by("-date").live().public().last()
53+
BlogPage.objects.filter(date__gt=page.date)
54+
.order_by("-date")
55+
.live()
56+
.public()
57+
.last()
5058
)
5159
if sibling:
5260
return sibling.specific

0 commit comments

Comments
 (0)