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

This commit is contained in:
Pēteris Caune 2019-09-18 14:56:58 +03:00
parent accdfb637b
commit ca5e19fd2d
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
2 changed files with 13 additions and 3 deletions

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="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"

View File

@ -16,7 +16,8 @@ def token(request):
def pricing(request):
if request.user.is_authenticated and request.user != request.project.owner:
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)