Compare locked_by_id to avoid fetching user object in _locked_indicator.html

pull/11461/head
Sage Abdullah 2024-02-07 14:27:45 +00:00 zatwierdzone przez Matt Westcott
rodzic 9f5e115355
commit 606f8607c2
2 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -8,8 +8,8 @@
{% if page.locked %}
<span
class="indicator locked-indicator {% if page.locked_by == request.user %}indicator--is-inverse{% endif %}"
title="{% if page.locked_by == request.user %}{% trans 'This page is locked, by you, to further editing' %}{% else %}{% trans 'This page is locked to further editing' %}{% endif %}"
class="indicator locked-indicator {% if page.locked_by_id == request.user.pk %}indicator--is-inverse{% endif %}"
title="{% if page.locked_by_id == request.user.pk %}{% trans 'This page is locked, by you, to further editing' %}{% else %}{% trans 'This page is locked to further editing' %}{% endif %}"
>
{% icon name="lock" classname="initial" %}
</span>

Wyświetl plik

@ -186,7 +186,7 @@ class TestRecentEditsQueryCount(WagtailTestUtils, TestCase):
# Warm up the cache
html = panel.render_html(parent_context)
with self.assertNumQueries(14):
with self.assertNumQueries(12):
# Rendering RecentEditsPanel should not generate N+1 queries -
# i.e. any number less than 6 would be reasonable here
html = panel.render_html(parent_context)
@ -229,7 +229,7 @@ class TestLockedPagesQueryCount(WagtailTestUtils, TestCase):
# Warm up the cache
html = panel.render_html(parent_context)
with self.assertNumQueries(4):
with self.assertNumQueries(1):
html = panel.render_html(parent_context)
soup = self.get_soup(html)
# Should be sorted descending by locked_at
@ -297,7 +297,7 @@ class UserObjectsInWorkflowModerationQueryCount(WagtailTestUtils, TestCase):
# Warm up the cache
html = panel.render_html(parent_context)
with self.assertNumQueries(6):
with self.assertNumQueries(4):
html = panel.render_html(parent_context)
soup = self.get_soup(html)
@ -387,7 +387,7 @@ class WorkflowObjectsToModerateQueryCount(WagtailTestUtils, TestCase):
# Warm up the cache
html = panel.render_html(parent_context)
with self.assertNumQueries(40):
with self.assertNumQueries(38):
html = panel.render_html(parent_context)
soup = self.get_soup(html)