Files
Chad Whitacre 28cb48c72a Big changeover from id to username; #287
I sort of did this one with the blast shield down. I haven't even run
the tests yet. The sorts of things I changed:

 - SQL {elsewhere,exchanges}.participant_id => .participant
 - SQL participants.id => .username
 - ORM {user,participant,self}.id => .username
2013-04-05 15:48:59 -04:00

106 lines
3.5 KiB
HTML

from aspen import Response
from gittip import AMOUNTS
from gittip.utils import get_participant
tip_suggestions = ('jeresig', 'antirez', 'wycats', 'fabpot', 'mitsuhiko',
'jtauber', 'kennethreitz', 'alex', 'taylorotwell')
tip_suggestions = [{'tippee': name, 'amount': 0} for name in tip_suggestions]
def _extract_username(tip):
if tip['platform'] == 'github':
key = 'login'
elif tip['platform'] == 'bitbucket':
key = 'username'
else:
assert tip['platform'] == 'twitter', tip # sanity check
key = 'screen_name'
return tip['user_info'][key]
# ========================================================================== ^L
participant = get_participant(request, restrict=True)
tips, total, unclaimed_tips, unclaimed_total = \
participant.get_giving_for_profile()
suggest_tips = (total == 0) and (user == participant)
if suggest_tips:
tips = tip_suggestions
hero = "Giving"
title = "%s - %s" % (participant.username, hero)
locked = False
# ========================================================================== ^L
{% extends "templates/profile.html" %}
{% block page %}
<style>
#matrix {
margin: 0 auto;
}
#matrix td {
text-align: left;
height: 30px;
}
#matrix th {
vertical-align: middle;
padding-right: 0.5em;
}
</style>
<table id="matrix">
<tr>
<td colspan="2">
{% if participant == user %}
<h2>You give $<span class="total-giving">{{ total }}</span> per
week</h2>
{% if total == 0 %}
<h2>Not sure who to give to? Here are some suggestions</h2>
{% end %}
{% else %}
<h2>{{ participant.username }} gives ${{ total }} per week</h2>
{% end %}
</td>
</tr>
{% for tip in tips %}
{% if tip['amount'] > 0 or suggest_tips %}
<tr>
<th><a href="/{{ tip['tippee'] }}/">{{ tip['tippee'] }}</a></th>
<td>
{% for amount in AMOUNTS %}
<button amount="{{ amount }}" tippee="{{ tip['tippee'] }}"
class="{% if user == participant %}tip{% end %} {{ 'selected' if amount == tip['amount'] else 'empty' }}">{{ amount }}</button>
{% end %}
{% if tip['amount'] not in AMOUNTS %}
<button class="old-amount {% if user == participant %}tip{% end %} selected">{{ tip['amount'] }}</button>
{% end %}
</td>
</tr>
{% end %}
{% end %}
{% if unclaimed_total > 0 %}
<tr>
<td colspan="2">
<h2>Another ${{ unclaimed_total }} per week goes unclaimed</h2>
</td>
</tr>
{% end %}
{% for tip in unclaimed_tips %}
{% if tip['amount'] > 0 %}
<tr>
<th>
<img class="platform-icon" src="/assets/icons/{{ tip['platform'] }}.12.png" />
<a href="/{{ tip['tippee'] }}/">{{ _extract_username(tip) }}</a>
</th>
<td>
{% for amount in AMOUNTS %}
<button amount="{{ amount }}" tippee="{{ tip['tippee'] }}"
class="{% if user == participant %}tip{% end %} {{ 'selected' if amount == tip['amount'] else 'empty' }}">{{ amount }}</button>
{% end %}
{% if tip['amount'] not in AMOUNTS %}
<button class="old-amount {% if user == participant %}tip{% end %} selected">{{ tip['amount'] }}</button>
{% end %}
</td>
</tr>
{% end %}
{% end %}
</table>
{% end %}