Browse Source

Don't throw an exception if user's current project is unset.

pull/291/head
Pēteris Caune 5 years ago
parent
commit
ca5e19fd2d
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
2 changed files with 13 additions and 3 deletions
  1. +9
    -0
      hc/payments/tests/test_pricing.py
  2. +4
    -3
      hc/payments/views.py

+ 9
- 0
hc/payments/tests/test_pricing.py View File

@ -35,6 +35,15 @@ class PricingTestCase(BaseTestCase):
r = self.client.get("/pricing/")
self.assertContains(r, "To manage billing for this project")
def test_it_handles_null_project(self):
self.profile.current_project = None
self.profile.save()
self.client.login(username="[email protected]", password="password")
r = self.client.get("/pricing/")
self.assertContains(r, "Unlimited Team Members")
def test_it_shows_active_plan(self):
self.sub = Subscription(user=self.alice)
self.sub.subscription_id = "test-id"


+ 4
- 3
hc/payments/views.py View File

@ -16,9 +16,10 @@ def token(request):
def pricing(request):
if request.user.is_authenticated and request.user != request.project.owner:
ctx = {"page": "pricing"}
return render(request, "payments/pricing_not_owner.html", ctx)
if request.user.is_authenticated:
if request.project and request.project.owner != request.user:
ctx = {"page": "pricing"}
return render(request, "payments/pricing_not_owner.html", ctx)
# Don't use Subscription.objects.for_user method here, so a
# subscription object is not created just by viewing a page.


Loading…
Cancel
Save