diff --git a/hc/payments/tests/test_pricing.py b/hc/payments/tests/test_pricing.py index f5becf87..815e1ddd 100644 --- a/hc/payments/tests/test_pricing.py +++ b/hc/payments/tests/test_pricing.py @@ -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="alice@example.org", 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" diff --git a/hc/payments/views.py b/hc/payments/views.py index 485b8f97..6405e655 100644 --- a/hc/payments/views.py +++ b/hc/payments/views.py @@ -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.