Only show published tags
This commit is contained in:
parent
552639ec40
commit
ae4ea780b7
5 changed files with 7 additions and 7 deletions
|
@ -79,7 +79,7 @@ class BlogPostPage(BaseContentPage):
|
||||||
else models.Value(1),
|
else models.Value(1),
|
||||||
)
|
)
|
||||||
|
|
||||||
page_tags = list(self.tags.values_list("id", flat=True))
|
page_tags = list(self.tags.public().live().values_list("id", flat=True))
|
||||||
similar_posts = similar_posts.alias(
|
similar_posts = similar_posts.alias(
|
||||||
# If this page has no tags, ignore it as part of similarity
|
# If this page has no tags, ignore it as part of similarity
|
||||||
# NB: Cast to a float, because `COUNT` returns a `bigint`.
|
# NB: Cast to a float, because `COUNT` returns a `bigint`.
|
||||||
|
|
|
@ -18,7 +18,7 @@ class BlogPostPageTestCase(TestCase):
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
def test_queries(self) -> None:
|
def test_queries(self) -> None:
|
||||||
with self.assertNumQueries(41):
|
with self.assertNumQueries(43):
|
||||||
self.client.get(self.page.url)
|
self.client.get(self.page.url)
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ class BlogPostListPageTestCase(TestCase):
|
||||||
self.assertEqual(len(response.context["listing_pages"]), 2)
|
self.assertEqual(len(response.context["listing_pages"]), 2)
|
||||||
|
|
||||||
def test_queries(self) -> None:
|
def test_queries(self) -> None:
|
||||||
with self.assertNumQueries(37):
|
with self.assertNumQueries(39):
|
||||||
self.client.get(self.page.url)
|
self.client.get(self.page.url)
|
||||||
|
|
||||||
def test_feed_accessible(self) -> None:
|
def test_feed_accessible(self) -> None:
|
||||||
|
|
|
@ -20,14 +20,14 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if page.tags.all %}
|
{% if page.tags.public.live.all %}
|
||||||
<div class="icon-text is-family-code">
|
<div class="icon-text is-family-code">
|
||||||
<span class="icon">
|
<span class="icon">
|
||||||
<a href="{{ page.tag_list_page_url }}" title="View all tags">
|
<a href="{{ page.tag_list_page_url }}" title="View all tags">
|
||||||
<i class="fas fa-lg fa-tags"></i>
|
<i class="fas fa-lg fa-tags"></i>
|
||||||
</a>
|
</a>
|
||||||
</span>
|
</span>
|
||||||
{% for tag in page.tags.all|dictsort:"slug" %}
|
{% for tag in page.tags.public.live.all|dictsort:"slug" %}
|
||||||
<span><a title="{{ tag.name }}" href="{% pageurl tag %}">#{{ tag.slug }}</a></span>
|
<span><a title="{{ tag.name }}" href="{% pageurl tag %}">#{{ tag.slug }}</a></span>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -127,7 +127,7 @@ class AllPagesFeed(Feed):
|
||||||
|
|
||||||
def item_categories(self, item: BasePage) -> Optional[list[str]]:
|
def item_categories(self, item: BasePage) -> Optional[list[str]]:
|
||||||
if tags := getattr(item, "tags", None):
|
if tags := getattr(item, "tags", None):
|
||||||
return tags.order_by("slug").values_list("slug", flat=True)
|
return tags.public().live().order_by("slug").values_list("slug", flat=True)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def item_enclosure_url(self, item: BasePage) -> Optional[str]:
|
def item_enclosure_url(self, item: BasePage) -> Optional[str]:
|
||||||
|
|
|
@ -17,7 +17,7 @@ class TagView(RedirectView):
|
||||||
permanent = True
|
permanent = True
|
||||||
|
|
||||||
def get_redirect_url(self, slug: str) -> str:
|
def get_redirect_url(self, slug: str) -> str:
|
||||||
tag = get_object_or_404(BlogPostTagPage, slug=slug)
|
tag = get_object_or_404(BlogPostTagPage.objects.public().live(), slug=slug)
|
||||||
return tag.get_url(request=self.request)
|
return tag.get_url(request=self.request)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue