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

Commit

Permalink
Implement a whitelisting review UI (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Nov 8, 2012
1 parent 8485851 commit f1ac715
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 6 deletions.
26 changes: 20 additions & 6 deletions www/%participant_id/toggle-is-suspicious.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,28 @@ from gittip import db
if not user.ADMIN:
raise Response(400)

rec = db.fetchone("""
to = body.get('to')
if not to in ('true', 'false', None):
raise Response(400)

if to is None:
rec = db.fetchone("""

UPDATE participants
SET is_suspicious = (is_suspicious IS NULL) OR (is_suspicious IS false)
WHERE id=%s
RETURNING is_suspicious

""", (path['participant_id'],))
else:
rec = db.fetchone("""

UPDATE participants
SET is_suspicious = (is_suspicious IS NULL) OR (is_suspicious IS false)
WHERE id=%s
RETURNING is_suspicious
UPDATE participants
SET is_suspicious = %s
WHERE id=%s
RETURNING is_suspicious

""", (path['participant_id'],))
""", (to == 'true', path['participant_id'],))

assert rec is not None

Expand Down
78 changes: 78 additions & 0 deletions www/about/fraud/review.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
from aspen import Response
from gittip import db

^L
if not user.ADMIN:
raise Response(404)


unreviewed = db.fetchall("""

SELECT id
, balance
FROM participants
WHERE is_suspicious IS NULL
AND ( last_bill_result IS NOT NULL
OR last_ach_result IS NOT NULL
)

""")
if unreviewed is None:
unreviewed = []
unreviewed = list(unreviewed)

^L
{% extends templates/base.html %}
{% block body %}
<style>
TABLE {
width: auto;
}
TD, TH {
text-align: left;
vertical-align: top;
}
</style>
<script>
$(document).ready(function()
{
function error(a,b,c)
{
console.log(a,b,c);
alert("Failed!");
}

$('BUTTON').click(function()
{
var row = $(this).parent();
var to = $(this).text() !== 'Good';
var participant_id = row.attr('participant_id');
var url = "/" + participant_id + "/toggle-is-suspicious.json";

function success()
{
row.remove();
}

jQuery.ajax({ url: url
, type: "POST"
, dataType: "json"
, data: {to: to}
, success: success
, error: error
})
});
});
</script>
<h3>Unreviewed Accounts (N = {{ len(unreviewed) }})</h3>
{% for account in unreviewed %}
<div participant_id="{{ account['id'] }}">
<button class="good small selected">Good</button>
<button class="bad small">Bad</button>
<a href="/{{ account['id'] }}/">{{ account['id'] }}</a>
</div>
{% end %}
<br />
<hr />
{% end %}

0 comments on commit f1ac715

Please sign in to comment.