Browse Source

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

pull/50/head
Pēteris Caune 9 years ago
parent
commit
636710f4f0
2 changed files with 5 additions and 3 deletions
  1. +2
    -2
      hc/payments/tests/test_pricing.py
  2. +3
    -1
      hc/payments/views.py

+ 2
- 2
hc/payments/tests/test_pricing.py 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
assert Subscription.objects.count() == 1
# A subscription object still should have NOT been created
assert Subscription.objects.count() == 0

+ 3
- 1
hc/payments/views.py 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",


Loading…
Cancel
Save