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

Commit

Permalink
Merge pull request #2986 from gratipay/fix-team-anonymous-receiving
Browse files Browse the repository at this point in the history
Fix anonymous receiving for teams
  • Loading branch information
Changaco committed Dec 14, 2014
2 parents 54a82b5 + 4c49b2c commit 5330e61
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
3 changes: 3 additions & 0 deletions branch.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BEGIN;
UPDATE participants SET anonymous_receiving=FALSE WHERE number='plural';
END;
11 changes: 11 additions & 0 deletions tests/py/test_anonymous_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ def test_participant_can_toggle_anonymous_receiving(self):
actual = json.loads(response.body)
assert actual['receiving'] is True

def test_team_cannot_toggle_anonymous_receiving(self):
self.make_participant('team', number='plural')
response = self.client.PxST(
'/team/anonymous.json',
auth_as='team',
data={'toggle': 'receiving'}
)
actual = response.code
expected = 400
assert actual == expected

def test_participant_can_toggle_anonymous_giving_back(self):
response = self.hit_anonymous('POST', data={'toggle': 'giving'})
response = self.hit_anonymous('POST', data={'toggle': 'giving'})
Expand Down
2 changes: 2 additions & 0 deletions www/%username/account/index.html.spt
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ emails = participant.get_emails()
{{ _("Hide total giving from others.") }}
</label>
<br />
{% if participant.IS_SINGULAR %}
<label tabindex="105" class="anonymous-receiving">
<input type="checkbox"
{% if participant.anonymous_receiving %}checked="true"{% endif %} />
{{ _("Hide total receiving from others.") }}
</label>
{% endif %}
</p>
{% if not user.ANON and (user.ADMIN or user.participant == participant) %}
<h2>{{ _("Available Money") }}</h2>
Expand Down
2 changes: 2 additions & 0 deletions www/%username/anonymous.json.spt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if POST:
field = body.get("toggle", "giving")
if field not in ["giving", "receiving"]:
raise Response(400)
if user.participant.IS_PLURAL and field == "receiving":
raise Response(400)
rec = website.db.one("""

UPDATE participants
Expand Down

0 comments on commit 5330e61

Please sign in to comment.