Make home button filters configurable
All checks were successful
Build and Push Docker Image / build (push) Successful in 27s
All checks were successful
Build and Push Docker Image / build (push) Successful in 27s
This commit is contained in:
@@ -103,6 +103,24 @@ class HomePopularProductsTests(TestCase):
|
||||
self.assertContains(response, 'href="/catalog/custom-left/?new=1"', html=False)
|
||||
self.assertContains(response, 'href="/catalog/custom-right/?sale=1"', html=False)
|
||||
|
||||
@override_settings(
|
||||
HOME_ADVANTAGES_LEFT_CATEGORY_SLUG="custom-left",
|
||||
HOME_ADVANTAGES_RIGHT_CATEGORY_SLUG="custom-right",
|
||||
HOME_ADVANTAGES_LEFT_NEW_FILTER=False,
|
||||
HOME_ADVANTAGES_RIGHT_SALE_FILTER=False,
|
||||
)
|
||||
def test_home_advantages_filter_flags_are_optional(self):
|
||||
Category.objects.create(name="Custom left", slug="custom-left")
|
||||
Category.objects.create(name="Custom right", slug="custom-right")
|
||||
|
||||
response = self.client.get(reverse("home"))
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, 'href="/catalog/custom-left/"', html=False)
|
||||
self.assertContains(response, 'href="/catalog/custom-right/"', html=False)
|
||||
self.assertNotContains(response, 'href="/catalog/custom-left/?new=1"', html=False)
|
||||
self.assertNotContains(response, 'href="/catalog/custom-right/?sale=1"', html=False)
|
||||
|
||||
|
||||
class FaviconTests(SimpleTestCase):
|
||||
def test_favicon_route_returns_icon(self):
|
||||
|
||||
@@ -92,11 +92,11 @@ def index(request):
|
||||
"home_products": home_products,
|
||||
"home_advantages_left_url": build_home_category_url(
|
||||
settings.HOME_ADVANTAGES_LEFT_CATEGORY_SLUG,
|
||||
new="1",
|
||||
new="1" if settings.HOME_ADVANTAGES_LEFT_NEW_FILTER else "",
|
||||
),
|
||||
"home_advantages_right_url": build_home_category_url(
|
||||
settings.HOME_ADVANTAGES_RIGHT_CATEGORY_SLUG,
|
||||
sale="1",
|
||||
sale="1" if settings.HOME_ADVANTAGES_RIGHT_SALE_FILTER else "",
|
||||
),
|
||||
"favorite_item_ids": get_user_favorite_item_ids(request.user),
|
||||
"cart_item_ids": get_user_cart_item_ids(request.user),
|
||||
|
||||
Reference in New Issue
Block a user