Don't use Subscription.objects.for_user method here, so a subscription object is not created just by viewing a page.

This commit is contained in:
Pēteris Caune 2016-03-11 12:24:19 +02:00
parent 93402c9c13
commit 636710f4f0
2 changed files with 5 additions and 3 deletions

View File

@ -17,5 +17,5 @@ class PricingTestCase(BaseTestCase):
r = self.client.get("/pricing/") r = self.client.get("/pricing/")
self.assertContains(r, "Unlimited Checks", status_code=200) self.assertContains(r, "Unlimited Checks", status_code=200)
# A subscription object should have been created # A subscription object still should have NOT been created
assert Subscription.objects.count() == 1 assert Subscription.objects.count() == 0

View File

@ -30,7 +30,9 @@ def get_client_token(request):
def pricing(request): def pricing(request):
sub = None sub = None
if request.user.is_authenticated(): 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 = { ctx = {
"page": "pricing", "page": "pricing",