Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Fix is_visible when publication_date==today
Maciej Korycinskia5a9fd67a6ef
diff --git a/saleor/core/models.py b/saleor/core/models.pyindex 1de36ccd6a..11a36da026 100644--- a/saleor/core/models.py+++ b/saleor/core/models.py@@ -71,7 +71,7 @@ class PublishableModel(models.Model):def is_visible(self):return self.is_published and (self.publication_date is None- or self.publication_date < datetime.date.today()+ or self.publication_date <= datetime.date.today())diff --git a/saleor/product/tests/test_product_availability.py b/saleor/product/tests/test_product_availability.pyindex f46f61b53d..a8fd5cf0b4 100644--- a/saleor/product/tests/test_product_availability.py+++ b/saleor/product/tests/test_product_availability.py@@ -2,6 +2,7 @@ import datetimefrom decimal import Decimalfrom unittest.mock import Mock+from freezegun import freeze_timefrom prices import Money, TaxedMoney, TaxedMoneyRangefrom ...plugins.manager import PluginsManager@@ -126,6 +127,13 @@ def test_available_products_only_available(product_list):assert all([product.is_visible for product in available_products])+@freeze_time("2020-03-18 12:00:00")+def test_product_is_visible_from_today(product):+ product.publication_date = datetime.date.today()+ product.save()+ assert product.is_visible++def test_available_products_with_variants(product_list):product = product_list[0]product.variants.all().delete()