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

163 lines
5.0 KiB
HTML

"""Twitter user page on Gittip.
"""
import datetime
import decimal
import requests
from aspen import json, Response, log
from aspen.utils import to_age, utc
from gittip import AMOUNTS, CARDINALS, db
from gittip.elsewhere import twitter
from gittip.models import Participant
# ========================================================================== ^L
# Try to load from Twitter.
# =========================
user_info = twitter.get_user_info(path['screen_name'])
# Try to load from Gittip.
# ========================
username = user_info['screen_name']
name = user_info.get('name')
if not name:
name = username
url = user_info['html_url'] = "https://twitter.com/%s" % username
account = twitter.TwitterAccount(user_info['id'], user_info)
participant = Participant.query.get(account.participant)
if account.is_claimed:
request.redirect('/%s/' % participant.username)
locked = account.is_locked
lock_action = "unlock" if account.is_locked else "lock"
nbackers = participant.get_number_of_backers()
title = username
# ========================================================================== ^L
{% extends templates/base.html %}
{% block heading %}<h2 class="top"><span>Twitter</span></h2>{% end %}
{% block box %}
<table class="on-elsewhere">
<tr>
<td class="picture">
<img src="{{ participant.get_img_src(128) }}" />
</td>
<td class="ready">
<h2><a href="{{ url }}">{{ escape(username) }}</a> has</h2>
<div class="number">{{ nbackers }}</div>
<div class="unit">{{ 'person' if nbackers == 1 else 'people' }} ready to give</div>
</td>
<td class="offset"></td>
</tr>
</table>
<div class="nav level-1">
{% if account.is_locked %}
<div class="help with-padding">
This account has been locked by its owner.
</div>
{% elif user.ANON %}
<h2>Your Weekly Gift</h2>
{% for amount in AMOUNTS %}
<button class="tip-anon">${{ amount }}</button>
{% end %}
<div class="help with-padding">Sign in using
<a class="highlight flash-me" href="{{ twitter.oauth_url(website, u'opt-in', path.decoded) }}">Twitter</a> or
<a href="{{ github.oauth_url(website, u'opt-in', path.decoded) }}">GitHub</a>
to pledge to <b>{{ escape(username) }}</b>.</div>
{% else %}
{% set my_tip = user.get_tip_to(participant.username) %}
<h2>Your Weekly Pledge</h2>
{% for amount in AMOUNTS %}
<button amount="{{ amount }}" tippee="{{ participant.username }}"
class="tip{{ ' selected' if amount == my_tip else '' }}">${{ amount }}</button>
{% end %}
{% if my_tip not in AMOUNTS %}
<span class="old-amount">
<button class="tip disabled selected">{{ my_tip }}</button>
<span class="old-amount-link">&mdash;
<a href="http://blog.gittip.com/post/26505682007/is-personal-funding-viable" target="_blank">old amount</a>!</span>
</span>
{% end %}
{% if user.last_bill_result is None %}
<div id="payment-prompt" class="help{% if my_tip > 0 %} needed{% end %}">
Back your gift with a <a href="/credit-card.html"
class="highlight">credit card</a> to make sure it goes
through!</div>
{% elif user.last_bill_result %}
<div id="payment-prompt" class="help really-needed">Fix your <a
href="/credit-card.html" class="highlight">credit
card</a> to make sure your gifts go through!</div>
{% end %}
{% end %}
</div>
{% end %}
{% block page %}
<div class="col0">
{% if account.is_locked %}
<h2>{{ escape(username) }} has opted out of Gittip.</h2>
<p>If you are <a href="{{ user_info.get('html_url', '') }}">{{ escape(username) }}</a>
on Twitter, you can unlock your account to allow people to pledge tips to
you on Gittip.</p>
<a href="{{ twitter.oauth_url(website, u'unlock', username) }}"
><button>Unlock</button></a>
{% else %}
<script>
$(document).ready(Gittip.initTipButtons);
</script>
<h2>{{ escape(name) }} has not joined Gittip.</h2>
<p>Is this you?
{% if user.ANON %}
<a href="{{ twitter.oauth_url(website, u'opt-in', username) }}">Click
here</a> to opt in to Gittip. We never collect money for you until
you do.
{% else %}
<a href="/sign-out.html">Sign out</a> and sign back in
to claim this account
{% end %}
</p>
{% if user.ANON %}
<h2>What is Gittip?</h2>
<p>Gittip is a way to thank and support your favorite artists, musicians,
writers, programmers, etc. by setting up a small weekly cash gift to them.
<a href="/about/">Read more ...</a></p>
<h2>Don't like what you see?</h2>
<p>If you are {{ escape(username) }} you can explicitly opt out of Gittip
by locking this account. We don't allow new pledges to locked accounts.</p>
<a href="{{ twitter.oauth_url(website, u'lock', username) }}"
><button>Lock</button></a>
{% end %}
{% end %}
</div>
{% end %}