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

Commit

Permalink
Add UI on for toggling payin suspension (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Nov 1, 2012
1 parent b371085 commit 15776d6
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
38 changes: 36 additions & 2 deletions www/%participant_id/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@
.count SPAN.bar.green {
background: #2A8F79;
}
.payin-suspended {
border: 2px solid red;
}
</style>
<script>
$(document).ready(function()
Expand Down Expand Up @@ -390,6 +393,35 @@
}
);
});

{% if user.ADMIN and participant['balanced_account_uri'] %}
// Wire up payin suspender.
// ========================

$('#payin-suspender').click(function()
{
jQuery.ajax(
{ url: 'toggle-payin-suspension.json'
, type: 'POST'
, dataType: 'json'
, success: function(data)
{
if (data.payin_suspended)
$('#balanced-account').addClass('payin-suspended');
else
$('#balanced-account').removeClass('payin-suspended');
var val = data.payin_suspended ? 'Uns' : 'S';
$('#payin-suspender').text(val + 'uspend Payins');
}
, error: function() {
alert( "Failed to toggle payin suspension. "
+ "Please try again."
);
}
}
);
});
{% end %}
});
</script>

Expand Down Expand Up @@ -677,9 +709,11 @@ <h3>Linked Accounts</h3>
</li>
{% end %}
{% if user.ADMIN and participant['balanced_account_uri'] %}
<li>
<li id="balanced-account"{% if participant['payin_suspended'] %} class="payin-suspended"{% end %}>
<img src="/assets/balanced-avatar.png" />
Balanced Payments<br />
Balanced Payments
<button id="payin-suspender" class="small">{{ 'Unsuspend' if participant['payin_suspended'] else 'Suspend' }} Payins</button>
<br />
<a href="https://www.balancedpayments.com/{{ participant['balanced_account_uri'][3:] }}">balancedpayments.com/...</a>
</li>
{% end %}
Expand Down
17 changes: 17 additions & 0 deletions www/%participant_id/toggle-payin-suspension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from gittip import db
^L
if not user.ADMIN:
raise Response(400)

rec = db.fetchone("""

UPDATE participants
SET payin_suspended = not payin_suspended
WHERE id=%s
RETURNING payin_suspended

""", (path['participant_id'],))

assert rec is not None

response.body = {"payin_suspended": rec['payin_suspended']}

0 comments on commit 15776d6

Please sign in to comment.