diff --git a/make_post_sell/models/shop.py b/make_post_sell/models/shop.py index f553d76..526c0d1 100644 --- a/make_post_sell/models/shop.py +++ b/make_post_sell/models/shop.py @@ -305,6 +305,8 @@ class Shop(RBase, Base): return False if self.trial_started_timestamp is None: return False + if self.trial_ended: + return False import time now = int(time.time() * 1000) return now < self.trial_expiry_timestamp @@ -313,6 +315,8 @@ class Shop(RBase, Base): def is_trial_expired(self): if self.plan_active or self.trial_started_timestamp is None: return False + if self.trial_ended: + return True import time now = int(time.time() * 1000) return now >= self.trial_expiry_timestamp @@ -341,6 +345,7 @@ class Shop(RBase, Base): return bool( self.primary_s3_enabled and self.primary_s3_endpoint + and self.primary_s3_region and self.primary_s3_bucket and self.primary_s3_access_key and self.primary_s3_secret_key @@ -884,6 +889,11 @@ def reforge_discovery_ring_async(shop_id, session_factory): shop = session.get(Shop, shop_id) if shop is None: return + if shop.environment is not None and shop.is_non_production: + shop.discovery_ring = [] + session.commit() + log.info("Ring cleared for non-production shop %s", shop.name) + return ring = compute_discovery_ring(shop) shop.discovery_ring = ring session.commit() diff --git a/make_post_sell/scripts/alembic/versions/f8201a9ba045_add_gift_card_tables_and_shop_settings.py b/make_post_sell/scripts/alembic/versions/f8201a9ba045_add_gift_card_tables_and_shop_settings.py index d1e5ac1..f4940ac 100644 --- a/make_post_sell/scripts/alembic/versions/f8201a9ba045_add_gift_card_tables_and_shop_settings.py +++ b/make_post_sell/scripts/alembic/versions/f8201a9ba045_add_gift_card_tables_and_shop_settings.py @@ -100,9 +100,17 @@ def upgrade(): def downgrade(): - op.drop_table("mps_cart_gift_card") - op.drop_table("mps_gift_card_transaction") - op.drop_table("mps_gift_card") - op.drop_column("mps_shop", "gift_card_enabled") - op.drop_column("mps_shop", "gift_card_min_in_cents") - op.drop_column("mps_shop", "gift_card_max_in_cents") + if _table_exists("mps_cart_gift_card"): + op.drop_table("mps_cart_gift_card") + if _table_exists("mps_gift_card_transaction"): + op.drop_table("mps_gift_card_transaction") + if _table_exists("mps_gift_card"): + op.drop_table("mps_gift_card") + if _column_exists("mps_cart", "json_gift_cards"): + op.drop_column("mps_cart", "json_gift_cards") + if _column_exists("mps_shop", "gift_card_enabled"): + op.drop_column("mps_shop", "gift_card_enabled") + if _column_exists("mps_shop", "gift_card_min_in_cents"): + op.drop_column("mps_shop", "gift_card_min_in_cents") + if _column_exists("mps_shop", "gift_card_max_in_cents"): + op.drop_column("mps_shop", "gift_card_max_in_cents") diff --git a/make_post_sell/tests/test_models.py b/make_post_sell/tests/test_models.py index 3894fb7..3583470 100644 --- a/make_post_sell/tests/test_models.py +++ b/make_post_sell/tests/test_models.py @@ -2596,6 +2596,8 @@ class TestAsyncDiscoveryRing(unittest.TestCase): mock_shop = mock.Mock() mock_shop.products = [] mock_shop.name = "test" + mock_shop.environment = 0 + mock_shop.is_non_production = False # Patch Session and compute to block until we signal with mock.patch("make_post_sell.models.shop.SASession") as MockSession: @@ -2642,6 +2644,8 @@ class TestAsyncDiscoveryRing(unittest.TestCase): mock_shop = mock.Mock() mock_shop.products = [] mock_shop.name = "test" + mock_shop.environment = 0 + mock_shop.is_non_production = False call_count = [0] @@ -2701,6 +2705,8 @@ class TestAsyncDiscoveryRing(unittest.TestCase): mock_shop = mock.Mock() mock_shop.products = [] mock_shop.name = "test" + mock_shop.environment = 0 + mock_shop.is_non_production = False call_count = [0] @@ -2758,6 +2764,8 @@ class TestAsyncDiscoveryRing(unittest.TestCase): mock_shop = mock.Mock() mock_shop.products = [] mock_shop.name = "test" + mock_shop.environment = 0 + mock_shop.is_non_production = False call_count = [0]