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

Commit

Permalink
Start a fraud dashboard (#355)
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Nov 6, 2012
1 parent d1ec229 commit e3e6800
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions www/about/fraud/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
from aspen import Response
from gittip import db

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


_suspicious = db.fetchall("""

SELECT id
, balance
FROM participants
WHERE payin_suspended

""")
if _suspicious is None:
_suspicious = []


def suspicious():
for person in _suspicious:
person['gives_to'] = db.fetchall("""

SELECT DISTINCT tippee AS id
, payin_suspended AS is_suspicious
FROM tips
JOIN participants p
ON tippee = p.id
WHERE tipper=%s


""", (person['id'],))
person['receives_from'] = db.fetchall("""

SELECT DISTINCT tipper AS id
, payin_suspended AS is_suspicious
FROM tips
JOIN participants p
ON tipper = p.id
WHERE tippee=%s

""", (person['id'],))
yield person
suspicious = suspicious()

^L
{% extends templates/base.html %}
{% block body %}
<style>
TABLE {
width: auto;
}
TD, TH {
text-align: left;
vertical-align: top;
border-bottom: 1px solid #B2A196;
}
.amount {
text-align: right;
padding-right: 1em;
font-family: Lucida Mono, monospace;
}
.suspicious {
font-weight: bold;
color: red;
}
</style>
<h3>Fraud, Grommit!</h3>
<table>
<tr>
<th>Suspicious Person</th>
<th></th>
<th>Balance</th>
<th>Gives To</th>
<th>Receives From</th>
</tr>
{% for row in suspicious %}
<tr>
<td><a href="/{{ row['id'] }}/">{{ row['id'] }}</a></td>
<td class="dollar-sign">$</td>
<td class="amount">{{ row['balance'] }}</td>
<td>
{% for person in row['gives_to'] %}
<a href="/{{ person['id'] }}/"{% if person['is_suspicious'] %} class="suspicious"{% end %}>{{ person['id'] }}</a><br />
{% end %}
</td>
<td>
{% for person in row['receives_from'] %}
<a href="/{{ person['id'] }}/"{% if person['is_suspicious'] %} class="suspicious"{% end %}>{{ person['id'] }}</a><br />
{% end %}
</td>
</tr>
{% end %}
</table>
<br />
<hr />
{% end %}

0 comments on commit e3e6800

Please sign in to comment.