diff --git a/hc/payments/context_processors.py b/hc/payments/context_processors.py index 6580e41b..27da5020 100644 --- a/hc/payments/context_processors.py +++ b/hc/payments/context_processors.py @@ -2,12 +2,4 @@ from django.conf import settings def payments(request): - - show_pricing = settings.USE_PAYMENTS - if show_pricing and request.user.is_authenticated: - if request.profile != request.team: - # Hide "Pricing" tab when user is not working on their - # own team - show_pricing = False - - return {'show_pricing': show_pricing} + return {'show_pricing': settings.USE_PAYMENTS} diff --git a/hc/payments/tests/test_pricing.py b/hc/payments/tests/test_pricing.py index 2c6970e6..f53fe6b2 100644 --- a/hc/payments/tests/test_pricing.py +++ b/hc/payments/tests/test_pricing.py @@ -23,18 +23,15 @@ class PricingTestCase(BaseTestCase): assert Subscription.objects.count() == 0 @override_settings(USE_PAYMENTS=True) - def test_pricing_is_hidden_for_team_members(self): + def test_pricing_is_visible_for_all(self): + for email in ("alice@example.org", "bob@example.org"): + self.client.login(username=email, password="password") - self.client.login(username="bob@example.org", password="password") - - r = self.client.get("/about/") - # Bob should not see pricing tab, as bob is currently on - # Alice's team, but is not its owner. - self.assertNotContains(r, "Pricing") + r = self.client.get("/about/") + self.assertContains(r, "Pricing") - @override_settings(USE_PAYMENTS=True) - def test_pricing_is_visible_for_team_owners(self): - self.client.login(username="alice@example.org", password="password") + def test_it_offers_to_switch(self): + self.client.login(username="bob@example.org", password="password") - r = self.client.get("/about/") - self.assertContains(r, "Pricing") + r = self.client.get("/pricing/") + self.assertContains(r, "To manage this team") diff --git a/hc/payments/views.py b/hc/payments/views.py index 5ae0f97e..e0e173de 100644 --- a/hc/payments/views.py +++ b/hc/payments/views.py @@ -28,6 +28,10 @@ def get_client_token(request): def pricing(request): + if request.user.is_authenticated and request.profile != request.team: + ctx = {"page": "pricing"} + return render(request, "payments/pricing_not_owner.html", ctx) + sub = None if request.user.is_authenticated: # Don't use Subscription.objects.for_user method here, so a diff --git a/templates/payments/pricing.html b/templates/payments/pricing.html index 5795e8f0..711a33ef 100644 --- a/templates/payments/pricing.html +++ b/templates/payments/pricing.html @@ -264,7 +264,9 @@