forked from GithubBackups/healthchecks
Team Access refinements.
This commit is contained in:
parent
e20fbd7783
commit
b725b5c4a5
@ -99,3 +99,13 @@ class ProfileTestCase(BaseTestCase):
|
||||
|
||||
self.alice.profile.refresh_from_db()
|
||||
self.assertEqual(self.alice.profile.team_name, "Alpha Team")
|
||||
|
||||
def test_it_switches_to_own_team(self):
|
||||
self.client.login(username="bob@example.org", password="password")
|
||||
|
||||
self.client.get("/accounts/profile/")
|
||||
|
||||
# After visiting the profile page, team should be switched back
|
||||
# to user's default team.
|
||||
self.bobs_profile.refresh_from_db()
|
||||
self.assertEqual(self.bobs_profile.current_team, self.bobs_profile)
|
||||
|
@ -121,6 +121,11 @@ def check_token(request, username, token):
|
||||
@login_required
|
||||
def profile(request):
|
||||
profile = request.user.profile
|
||||
# Switch user back to its default team
|
||||
if profile.current_team_id != profile.id:
|
||||
request.team = profile
|
||||
profile.current_team_id = profile.id
|
||||
profile.save()
|
||||
|
||||
show_api_key = False
|
||||
if request.method == "POST":
|
||||
|
@ -2,4 +2,11 @@ from django.conf import settings
|
||||
|
||||
|
||||
def payments(request):
|
||||
return {'USE_PAYMENTS': settings.USE_PAYMENTS}
|
||||
|
||||
show_pricing = settings.USE_PAYMENTS
|
||||
if show_pricing and request.user.is_authenticated():
|
||||
profile = request.user.profile
|
||||
if profile.id != profile.current_team_id:
|
||||
show_pricing = False
|
||||
|
||||
return {'show_pricing': show_pricing}
|
||||
|
@ -19,3 +19,11 @@ class PricingTestCase(BaseTestCase):
|
||||
|
||||
# A subscription object still should have NOT been created
|
||||
assert Subscription.objects.count() == 0
|
||||
|
||||
def test_pricing_is_hidden_for_team_members(self):
|
||||
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")
|
||||
|
@ -83,7 +83,7 @@
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if USE_PAYMENTS %}
|
||||
{% if show_pricing %}
|
||||
<li {% if page == 'pricing' %} class="active" {% endif %}>
|
||||
<a href="{% url 'hc-pricing' %}">Pricing</a>
|
||||
</li>
|
||||
@ -152,7 +152,7 @@
|
||||
<ul>
|
||||
<li>© 2015-2016 Monkey See Monkey Do SIA</li>
|
||||
<li><a href="{% url 'hc-privacy' %}">Privacy</a></li>
|
||||
{% if USE_PAYMENTS %}
|
||||
{% if show_pricing %}
|
||||
<li><a href="{% url 'hc-pricing' %}">Pricing</a></li>
|
||||
{% endif %}
|
||||
<li><a href="{% url 'hc-about' %}">Contact</a></li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user