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:
2
.env
2
.env
@@ -11,6 +11,8 @@ SECURE_REFERRER_POLICY=strict-origin-when-cross-origin
|
||||
SITE_NAME=SantehRay
|
||||
HOME_ADVANTAGES_LEFT_CATEGORY_SLUG=santehnika
|
||||
HOME_ADVANTAGES_RIGHT_CATEGORY_SLUG=otoplenie
|
||||
HOME_ADVANTAGES_LEFT_NEW_FILTER=true
|
||||
HOME_ADVANTAGES_RIGHT_SALE_FILTER=true
|
||||
LOGIN_URL=/users/login/
|
||||
LOGIN_REDIRECT_URL=/users/profile/
|
||||
LOGOUT_REDIRECT_URL=/users/login/
|
||||
|
||||
@@ -11,6 +11,8 @@ SECURE_REFERRER_POLICY=strict-origin-when-cross-origin
|
||||
SITE_NAME=SantehRay
|
||||
HOME_ADVANTAGES_LEFT_CATEGORY_SLUG=santehnika
|
||||
HOME_ADVANTAGES_RIGHT_CATEGORY_SLUG=otoplenie
|
||||
HOME_ADVANTAGES_LEFT_NEW_FILTER=true
|
||||
HOME_ADVANTAGES_RIGHT_SALE_FILTER=true
|
||||
LOGIN_URL=/users/login/
|
||||
LOGIN_REDIRECT_URL=/users/profile/
|
||||
LOGOUT_REDIRECT_URL=/users/login/
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -341,6 +341,8 @@ SITE_NAME = os.getenv("SITE_NAME", "SantehRay")
|
||||
|
||||
HOME_ADVANTAGES_LEFT_CATEGORY_SLUG = os.getenv("HOME_ADVANTAGES_LEFT_CATEGORY_SLUG", "santehnika")
|
||||
HOME_ADVANTAGES_RIGHT_CATEGORY_SLUG = os.getenv("HOME_ADVANTAGES_RIGHT_CATEGORY_SLUG", "otoplenie")
|
||||
HOME_ADVANTAGES_LEFT_NEW_FILTER = env_bool("HOME_ADVANTAGES_LEFT_NEW_FILTER", True)
|
||||
HOME_ADVANTAGES_RIGHT_SALE_FILTER = env_bool("HOME_ADVANTAGES_RIGHT_SALE_FILTER", True)
|
||||
|
||||
LOGIN_URL = os.getenv("LOGIN_URL", "/users/login/")
|
||||
LOGIN_REDIRECT_URL = os.getenv("LOGIN_REDIRECT_URL", "/users/profile/")
|
||||
|
||||
Reference in New Issue
Block a user