diff --git a/tests/py/test_www_team_distributing.py b/tests/py/test_www_team_distributing.py index 4590bd9b5f..9ddd79eef9 100644 --- a/tests/py/test_www_team_distributing.py +++ b/tests/py/test_www_team_distributing.py @@ -13,3 +13,13 @@ def test_distributing_doesnt_redirect_when_money_is_available(self): self.make_team() self.db.run("UPDATE teams SET available=537") assert self.client.GET('/TheEnterprise/distributing/').code == 200 + + + def test_distributing_json_redirects_when_no_money_is_available(self): + self.make_team() + assert self.client.GxT('/TheEnterprise/distributing/index.json').code == 302 + + def test_distributing_json_doesnt_redirect_when_money_is_available(self): + self.make_team() + self.db.run("UPDATE teams SET available=537") + assert self.client.GET('/TheEnterprise/distributing/index.json', raise_immediately=False).code == 500 diff --git a/www/%team/distributing/index.json.spt b/www/%team/distributing/index.json.spt index 42453c0340..2a75c73892 100644 --- a/www/%team/distributing/index.json.spt +++ b/www/%team/distributing/index.json.spt @@ -1,14 +1,12 @@ """Endpoint to list team members. """ -from aspen import Response -from gratipay.utils import get_participant +from gratipay.utils import get_team [--------------------] -website.redirect('..', base_url='') # XXX Migrating to Teams! Fix this up! request.allow('GET') -team = get_participant(state, restrict=False) -if not team.show_as_team(user): - raise Response(404) +team = get_team(state) +if team.available == 0: + website.redirect('..', base_url='') [--------------------] application/json via json_dump team.get_members(user.participant)