Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Start bringing back individual member endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Jul 1, 2016
1 parent f76eeaf commit a89cd72
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/py/test_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def browse(self, setup=None, **kw):
.replace('/for/%slug/', '/for/wonderland/') \
.replace('/%platform/', '/github/') \
.replace('/%user_name/', '/gratipay/') \
.replace('/%membername', '/alan') \
.replace('/%member_id', '/1') \
.replace('/%country', '/TT') \
.replace('/%exchange_id.int', '/%s' % exchange_id) \
.replace('/%redirect_to', '/giving') \
Expand Down
14 changes: 12 additions & 2 deletions tests/py/test_www_team_distributing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@ def test_distributing_doesnt_redirect_when_money_is_available(self):
assert self.client.GET('/TheEnterprise/distributing/').code == 200


def test_distributing_json_redirects_when_no_money_is_available(self):
def test_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):
def test_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


def test_member_json_redirects_when_no_money_is_available(self):
self.make_team()
assert self.client.GxT('/TheEnterprise/distributing/1.json').code == 302

def test_member_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/1.json', raise_immediately=False).code == 500
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@ from decimal import Decimal, InvalidOperation

from aspen import Response
from babel.numbers import NumberFormatError
from gratipay.utils import get_participant
from gratipay.utils import get_team
from gratipay.models.participant import Participant

ZERO = Decimal('0.00')
A_PENNY = Decimal('0.01')

[--------------------]
website.redirect('..', base_url='') # XXX Migrating to Teams! Fix this up!
request.allow('GET', 'POST')
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='')

member = Participant.from_username(request.path['membername'])
member = Participant.from_id(request.path['member_id'])
if member is None or member.is_suspicious:
raise Response(404, _("User not found."))
is_member = member.member_of(team)
Expand Down

0 comments on commit a89cd72

Please sign in to comment.