From 636710f4f013ddf337061ee1b566d2328581a9c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Fri, 11 Mar 2016 12:24:19 +0200 Subject: [PATCH] Don't use Subscription.objects.for_user method here, so a subscription object is not created just by viewing a page. --- hc/payments/tests/test_pricing.py | 4 ++-- hc/payments/views.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/hc/payments/tests/test_pricing.py b/hc/payments/tests/test_pricing.py index 57ee9745..7a695ea4 100644 --- a/hc/payments/tests/test_pricing.py +++ b/hc/payments/tests/test_pricing.py @@ -17,5 +17,5 @@ class PricingTestCase(BaseTestCase): r = self.client.get("/pricing/") self.assertContains(r, "Unlimited Checks", status_code=200) - # A subscription object should have been created - assert Subscription.objects.count() == 1 + # A subscription object still should have NOT been created + assert Subscription.objects.count() == 0 diff --git a/hc/payments/views.py b/hc/payments/views.py index 9316115e..0f6765af 100644 --- a/hc/payments/views.py +++ b/hc/payments/views.py @@ -30,7 +30,9 @@ def get_client_token(request): def pricing(request): sub = None if request.user.is_authenticated(): - sub = Subscription.objects.for_user(request.user) + # Don't use Subscription.objects.for_user method here, so a + # subscription object is not created just by viewing a page. + sub = Subscription.objects.filter(user_id=request.user.id).first() ctx = { "page": "pricing",