mirror of
https://github.com/kennethreitz-archive/www.gittip.com.git
synced 2026-06-21 15:50:59 +00:00
104 lines
3.4 KiB
HTML
104 lines
3.4 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'
|
|
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.id, 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.id }} 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 %}
|