Skip to content

Commit

Permalink
PNI - Removed redundant get_bg_home_page usage (#12798)
Browse files Browse the repository at this point in the history
* removed redundant get_bg_home_page calls

* fixed linting error

* updated expected query numbers for various PNI tests
  • Loading branch information
mmmavis authored Sep 4, 2024
1 parent 6faca74 commit e27801a
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load bg_nav_tags wagtailcore_tags i18n static %}
{% get_bg_home_page as home_page %}
{% load wagtailcore_tags i18n static %}

<div class="container">
<img class="mb-3 oh-no-face" src="{% static '_images/buyers-guide/faces/oh-no.svg' %}" alt="{% trans "Sad face. No products were found." %}">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load bg_nav_tags i18n static wagtailcore_tags wagtailroutablepage_tags %}
{% get_bg_home_page as home_page %}

<div class="d-md-none mt-0 mb-0 tw-bg-white" id="pni-mobile-category-nav">
<div class="container">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load bg_nav_tags i18n wagtailroutablepage_tags wagtailcore_tags static %}
{% get_bg_home_page as home_page %}

{{ pre }}
{% with home_page.get_editorial_content_index as editorial_content_index %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{% block menu_container_classes %} tw-pb-0 {% endblock %}

{% block nav_logo %}
{% get_bg_home_page as home_page %}
<div class="tw-flex tw-flex-col logo-section tw-mx-auto large:tw-mx-0">
<p class="mb-0 tw-h3-heading tw-max-w-none flex-wrap">
<a class="link-back tw-flex" href="{% pageurl home_page %}">
Expand All @@ -26,7 +25,6 @@
{% endblock %}

{% block narrow_screen_nav_links %}
{% get_bg_home_page as home_page %}
{% include "fragments/buyersguide/pni_nav_links.html" with class="tw-block tw-w-fit" pre="<div>" post="</div>" %}
{% endblock %}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load wagtailcore_tags bg_selector_tags l10n i18n wagtailroutablepage_tags static bg_nav_tags %}
{% get_bg_home_page as home_page %}

<div id="product-tab" class="tw-w-full tw-mb-8">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
</div>
</div>
</div>
{% get_bg_home_page as home_page %}
{% bg_non_hidden_categories as categories %}
<div class="project-list-section">
<div class="container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@

{% block guts %}

{% get_bg_home_page as home_page %}

<div class="text-center product-header bg-product-image{% if product.draft %} draft-product{% endif %}">
<div class="tw-container tw-block medium:tw-grid tw-grid-cols-12 tw-gap-x-16">
<div class="tw-col-start-3 tw-col-end-11 tw--mx-8 medium:tw--mx-16">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_serve_page_no_products(self):
products = ProductPage.objects.descendant_of(self.bg)
products.delete()
self.assertEqual(products.count(), 0)
query_number = 52
query_number = 45

with self.assertNumQueries(query_number):
response = self.client.get(self.bg.url)
Expand All @@ -179,7 +179,7 @@ def test_serve_page_no_products(self):
def test_serve_page_one_product(self):
products = ProductPage.objects.descendant_of(self.bg)
self.assertEqual(products.count(), 1)
query_number = 67
query_number = 60

with self.assertNumQueries(query_number):
response = self.client.get(self.bg.url)
Expand All @@ -193,7 +193,7 @@ def test_serve_page_many_products(self):
buyersguide_factories.ProductPageFactory(parent=self.bg, with_random_categories=True)
products = ProductPage.objects.descendant_of(self.bg)
self.assertEqual(products.count(), additional_products_count + 1)
query_number = 68
query_number = 61

with self.assertNumQueries(query_number):
response = self.client.get(self.bg.url)
Expand All @@ -207,7 +207,7 @@ def test_serve_page_many_products_logged_in(self):
buyersguide_factories.ProductPageFactory(parent=self.bg, with_random_categories=True)
products = ProductPage.objects.descendant_of(self.bg)
self.assertEqual(products.count(), additional_products_count + 1)
query_number = 74
query_number = 67
self.client.force_login(user=self.create_test_user())

with self.assertNumQueries(query_number):
Expand Down

0 comments on commit e27801a

Please sign in to comment.