<commit_before>import traceback
from datetime import datetime, timedelta

import balanced
from aspen import json, log, Response
from gittip import billing, MONTHS
from gittip.elsewhere import github

# ========================================================================== ^L
balanced_account_uri = None
account = None
bank_account = None
status = ". . ."

if not user.ANON:
    balanced_account_uri = user.balanced_account_uri

    status = "not connected"
    if balanced_account_uri:
        working = user.last_ach_result == ""
        status = "connected" if working else "not connected"
        account = balanced.Account.find(balanced_account_uri)

        bank_account = billing.BalancedBankAccount(balanced_account_uri)
        if bank_account.is_setup:
            assert balanced_account_uri == bank_account['account_uri']

    username = user.id

title = "Bank Account"
# ========================================================================== ^L
{% extends templates/base.html %}

{% block heading %}

    <h2 class="top"><span>Your bank account is <em id="status">{{ status }}</em></span></h2>

    <p>When you receive money on Gittip we
    {% if bank_account and bank_account.is_setup %}will{% else %}can{% end %}
    automatically deposit it into your bank account. If you don't connect
    a bank account then your money will accumulate within Gittip unless you
    regift it to others.<p>

{% end %}

{% block box %}
  {% if user.ANON %}
    <div class="as-content">

    <p>Sign in using<commit_msg>Add debugging helper to bank-account.html; #791<commit_after>import traceback
from datetime import datetime, timedelta

import balanced
from aspen import json, log, Response
from gittip import billing, MONTHS
from gittip.elsewhere import github

# ========================================================================== ^L
balanced_account_uri = None
account = None
bank_account = None
status = ". . ."

if not user.ANON:
    balanced_account_uri = user.balanced_account_uri

    status = "not connected"
    if balanced_account_uri:
        working = user.last_ach_result == ""
        status = "connected" if working else "not connected"
        account = balanced.Account.find(balanced_account_uri)

        bank_account = billing.BalancedBankAccount(balanced_account_uri)
        if bank_account.is_setup:

            # Factored out to aid debugging. This extra var will show up in the
            # context on Sentry so we can compare the two values. See:
            #
            #   https://github.com/gittip/www.gittip.com/issues/791

            _bank_account_account_uri = bank_account['account_uri']

            assert balanced_account_uri == _bank_account_account_uri

    username = user.id

title = "Bank Account"
# ========================================================================== ^L
{% extends templates/base.html %}

{% block heading %}

    <h2 class="top"><span>Your bank account is <em id="status">{{ status }}</em></span></h2>

    <p>When you receive money on Gittip we
    {% if bank_account and bank_account.is_setup %}will{% else %}can{% end %}
    automatically deposit it into your bank account. If you don't connect
    a bank account then your money will accumulate within Gittip unless you
    regift it to others.<p>

{% end %}

{% block box %}
  {% if user.ANON %}
    <div class="as-content">

    <p>Sign in using
{'fraction_non_alphanumeric': 0.17532467532467533, 'fraction_numerical': 0.0029515938606847697, 'mean_word_length': 3.7200557103064065, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '77793', 'n_tokens_mistral': 990, 'n_tokens_neox': 897, 'n_words': 293}