forked from GithubBackups/healthchecks
Pricing in top nav is visible for team members too, but pricing page says "you are not the team owner".
This commit is contained in:
parent
888d7a1f9c
commit
6a57bcfdf3
@ -2,12 +2,4 @@ from django.conf import settings
|
|||||||
|
|
||||||
|
|
||||||
def payments(request):
|
def payments(request):
|
||||||
|
return {'show_pricing': settings.USE_PAYMENTS}
|
||||||
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}
|
|
||||||
|
@ -23,18 +23,15 @@ class PricingTestCase(BaseTestCase):
|
|||||||
assert Subscription.objects.count() == 0
|
assert Subscription.objects.count() == 0
|
||||||
|
|
||||||
@override_settings(USE_PAYMENTS=True)
|
@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="bob@example.org", password="password")
|
self.client.login(username=email, 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")
|
|
||||||
|
|
||||||
@override_settings(USE_PAYMENTS=True)
|
|
||||||
def test_pricing_is_visible_for_team_owners(self):
|
|
||||||
self.client.login(username="alice@example.org", password="password")
|
|
||||||
|
|
||||||
r = self.client.get("/about/")
|
r = self.client.get("/about/")
|
||||||
self.assertContains(r, "Pricing")
|
self.assertContains(r, "Pricing")
|
||||||
|
|
||||||
|
def test_it_offers_to_switch(self):
|
||||||
|
self.client.login(username="bob@example.org", password="password")
|
||||||
|
|
||||||
|
r = self.client.get("/pricing/")
|
||||||
|
self.assertContains(r, "To manage this team")
|
||||||
|
@ -28,6 +28,10 @@ def get_client_token(request):
|
|||||||
|
|
||||||
|
|
||||||
def pricing(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
|
sub = None
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
# Don't use Subscription.objects.for_user method here, so a
|
# Don't use Subscription.objects.for_user method here, so a
|
||||||
|
@ -264,7 +264,9 @@
|
|||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" data-dismiss="modal">×</button>
|
<button type="button" class="close" data-dismiss="modal">×</button>
|
||||||
<h4>Set Up Subscription</h4>
|
<h4>Set Up Subscription
|
||||||
|
<small>for {{ request.user.profile }}</small>
|
||||||
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div id="payment-form"></div>
|
<div id="payment-form"></div>
|
||||||
|
35
templates/payments/pricing_not_owner.html
Normal file
35
templates/payments/pricing_not_owner.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
{% load staticfiles compress %}
|
||||||
|
|
||||||
|
{% block title %}Pricing - healthchecks.io{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<section id="plans">
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="jumbotron">
|
||||||
|
<p>
|
||||||
|
You are currently viewing team <strong>{{ request.team }}</strong>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
To manage this team, please log in as <strong>{{ request.team.user.email }}</strong>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a class="btn btn-default"
|
||||||
|
href="{% url 'hc-switch-team' request.user.username %}">
|
||||||
|
Switch to {{ request.profile }}
|
||||||
|
</a>
|
||||||
|
<a class="btn btn-default" href="{% url 'hc-logout' %}">Log Out</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
Loading…
x
Reference in New Issue
Block a user