mirror of
https://github.com/kennethreitz-archive/www.gittip.com.git
synced 2026-06-21 15:50:59 +00:00
247 lines
9.4 KiB
HTML
247 lines
9.4 KiB
HTML
"""This is called as an internal redirect from /on/blah/associate
|
|
"""
|
|
import uuid
|
|
|
|
from aspen import Response
|
|
from gittip.models import Participant
|
|
|
|
website.connect_tokens = {}
|
|
|
|
# ===== ^L
|
|
if not getattr(request, 'internally_redirected_from', None):
|
|
raise Response(404)
|
|
|
|
if user.ANON:
|
|
raise Response(404)
|
|
|
|
|
|
# Compute and store a connect_token.
|
|
# ==================================
|
|
# This is a protection against unauthorized users taking over accounts.
|
|
|
|
connect_token = uuid.uuid4().hex
|
|
connect_key = (user.id, account.platform, account.user_id)
|
|
website.connect_tokens[connect_key] = connect_token
|
|
|
|
|
|
other = Participant.query.get(account.participant_id)
|
|
|
|
user_github_account, user_twitter_account = user.get_accounts_elsewhere()
|
|
other_github_account, other_twitter_account = other.get_accounts_elsewhere()
|
|
|
|
|
|
user_giving = user.get_dollars_giving()
|
|
user_receiving = user.get_dollars_receiving()
|
|
|
|
other_giving = other.get_dollars_giving()
|
|
other_receiving = other.get_dollars_receiving()
|
|
|
|
combined_giving = user_giving + other_giving
|
|
combined_receiving = user_receiving + other_receiving
|
|
|
|
fmt = lambda x: '$' + str(int(round(x))) if x > 0 else '-'
|
|
username = user_info['screen_name' if account.platform == 'twitter' else 'login']
|
|
|
|
title = "Please Confirm"
|
|
# ===== ^L
|
|
{% extends "templates/base.html" %}
|
|
{% block box %}
|
|
<div class="on-confirm">
|
|
|
|
<div><img class="platform-icon" src="/assets/icons/{{ account.platform }}.12.png"
|
|
/> <span class="highlight">{{ username }}</span> is connected<br />to
|
|
<b>{{ other.id }}</b> on Gittip.<br />Reconnect it?</div>
|
|
|
|
<h2>Now</h2>
|
|
|
|
<table class="scenario">
|
|
<tr>
|
|
<td></td>
|
|
<td>
|
|
<div class="participant">
|
|
<div class="participant-padding">
|
|
<b>{{ user.id }}</b><br />
|
|
<table>
|
|
<tr>
|
|
<th><i>Gives</i></th>
|
|
<td>{{ fmt(user_giving) }}</td>
|
|
</tr>
|
|
<tr>
|
|
<th><i>Receives</i></th>
|
|
<td>{{ fmt(user_receiving) }}</td>
|
|
</tr>
|
|
</table>
|
|
<br />
|
|
{% if user_github_account is not None %}
|
|
<img src="/assets/icons/github.12.png" />
|
|
{{ user_github_account.user_info['login'] }}<br />
|
|
{% end %}
|
|
{% if user_twitter_account is not None %}
|
|
<img src="/assets/icons/twitter.12.png" />
|
|
{{ user_twitter_account.user_info['screen_name'] }}<br />
|
|
{% end %}
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<div class="participant other">
|
|
<div class="participant-padding">
|
|
<b>{{ other.id }}</b><br />
|
|
<table>
|
|
<tr>
|
|
<th><i>Gives</i></th>
|
|
<td>{{ fmt(other_giving) }}</td>
|
|
</tr>
|
|
<tr>
|
|
<th><i>Receives</i></th>
|
|
<td>{{ fmt(other_receiving) }}</td>
|
|
</tr>
|
|
</table>
|
|
<br />
|
|
{% if other_github_account is not None %}
|
|
<img src="/assets/icons/github.12.png" />
|
|
{% if account.platform == 'github' %}<span class="highlight">{% end %}
|
|
{{ other_github_account.user_info['login'] }}<br />
|
|
{% if account.platform == 'github' %}</span>{% end %}
|
|
{% end %}
|
|
{% if other_twitter_account is not None %}
|
|
<img src="/assets/icons/twitter.12.png" />
|
|
{% if account.platform == 'twitter' %}<span class="highlight">{% end %}
|
|
{{ other_twitter_account.user_info['screen_name'] }}<br />
|
|
{% if account.platform == 'twitter' %}</span>{% end %}
|
|
{% end %}
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
<h2>After Reconnect</h2>
|
|
|
|
<table class="scenario">
|
|
<tr>
|
|
<td class="abandoned">
|
|
{% if account.platform == 'github' and user_github_account is not None %}
|
|
<span class="account-elsewhere">
|
|
<img src="/assets/icons/github.12.png" />
|
|
{{ user_github_account.user_info['login'] }}<br />
|
|
</span>
|
|
{% end %}
|
|
{% if account.platform == 'twitter' and user_twitter_account is not None %}
|
|
<span class="account-elsewhere">
|
|
<img src="/assets/icons/twitter.12.png" />
|
|
{{ user_twitter_account.user_info['screen_name'] }}<br />
|
|
</span>
|
|
{% end %}
|
|
</td>
|
|
<td>
|
|
<div class="participant">
|
|
<div class="participant-padding">
|
|
<b>{{ user.id }}</b><br />
|
|
<table>
|
|
<tr>
|
|
{% if obstacles.this_is_others_last_account_elsewhere %}
|
|
<th><i>Gives</i></th>
|
|
<td>{{ fmt(combined_giving) }}</td>
|
|
</tr>
|
|
<tr>
|
|
<th><i>Receives</i></th>
|
|
<td>{{ fmt(combined_receiving ) }}</td>
|
|
{% else %}
|
|
<th><i>Gives</i></th>
|
|
<td>{{ fmt(user_giving) }}</td>
|
|
</tr>
|
|
<tr>
|
|
<th><i>Receives</i></th>
|
|
<td>{{ fmt(user_receiving ) }}</td>
|
|
{% end %}
|
|
</tr>
|
|
</table>
|
|
<br />
|
|
|
|
{% if user_github_account is not None %}
|
|
<span class="account-elsewhere">
|
|
<img src="/assets/icons/github.12.png" />
|
|
{{ user_github_account.user_info['login'] }}<br />
|
|
</span>
|
|
{% end %}
|
|
{% if user_twitter_account is not None %}
|
|
<span class="account-elsewhere">
|
|
<img src="/assets/icons/twitter.12.png" />
|
|
{{ user_twitter_account.user_info['screen_name'] }}<br />
|
|
</span>
|
|
{% end %}
|
|
|
|
<span class="account-elsewhere">
|
|
<img src="/assets/icons/{{ account.platform }}.12.png" />
|
|
<span class="highlight">{{ username }}</span>
|
|
</span>
|
|
|
|
</div>
|
|
</div>
|
|
</td>
|
|
{% if obstacles.this_is_others_last_account_elsewhere %}
|
|
<td>
|
|
<div class="participant other nix">
|
|
<div class="participant-padding">
|
|
<img id="nix" src="/assets/nix.png" />
|
|
<b>{{ other.id }}</b><br />
|
|
<br />
|
|
</div>
|
|
</div>
|
|
</td>
|
|
{% else %}
|
|
<td>
|
|
<div class="participant other">
|
|
<div class="participant-padding">
|
|
<b>{{ other.id }}</b><br />
|
|
<table>
|
|
<tr>
|
|
<th><i>Gives</i></th>
|
|
<td>{{ fmt(other_giving) }}</td>
|
|
</tr>
|
|
<tr>
|
|
<th><i>Receives</i></th>
|
|
<td>{{ fmt(other_receiving ) }}</td>
|
|
</tr>
|
|
</table>
|
|
<br />
|
|
|
|
{% if other_github_account is not None and account.platform != 'github' %}
|
|
<span class="account-elsewhere">
|
|
<img src="/assets/icons/github.12.png" />
|
|
{{ other_github_account.user_info['login'] }}<br />
|
|
</span>
|
|
{% end %}
|
|
{% if other_twitter_account is not None and account.platform != 'twitter' %}
|
|
<span class="account-elsewhere">
|
|
<img src="/assets/icons/twitter.12.png" />
|
|
{{ other_twitter_account.user_info['screen_name'] }}<br />
|
|
</span>
|
|
{% end %}
|
|
|
|
</div>
|
|
</div>
|
|
</td>
|
|
{% end %}
|
|
</tr>
|
|
</table>
|
|
|
|
|
|
<div class="buttons nav">
|
|
<h2>Reconnect?</h2>
|
|
|
|
<form action="/on/take-over.html" method="POST">
|
|
<input type="hidden" name="platform" value="{{ account.platform }}" />
|
|
<input type="hidden" name="user_id" value="{{ account.user_id }}" />
|
|
<input type="hidden" name="csrf_token" value="{{ cookie['csrf_token'].value }}" />
|
|
<input type="hidden" name="connect_token" value="{{ connect_token }}" />
|
|
<button class="selected">Yes</button>
|
|
<a href="/about/me.html"><button>No</button></a>
|
|
</form>
|
|
</div>
|
|
|
|
</div>
|
|
{% end %}
|