Exemplo n.º 1
0
def render(name):
    # TODO: find a better way
    if name == 'api_request':
        spac = Spac.get_spac(session['id'])
        return spac.send_api_key(request.values['email'])

    from flask import get_template_attribute
    m = get_template_attribute('render.html', name)
    result = m(**dict(request.values.iteritems()))
    return make_response(result)
Exemplo n.º 2
0
def verify_invite_code():
    code = request.values.get('code')
    spac = Spac.all().filter('my_invite_code =', code).get()
    if not spac:
        return "Sorry, wrong invitation code."

    session['inviter'] = spac.key().name()
    t = datetime.now()
    session['fee'] = round(settings.SIGNUP_FEE - 0.01 + float("0.00%.2s%.2s%.2s" % (t.minute, t.second, t.microsecond)), 8)
    session['signup_status'] = 'waiting_for_payment'
    return redirect(request.values.get('next', '/'))
Exemplo n.º 3
0
def raise_bet(day):
    y, m, d = [int(x) for x in day.split("-")]
    a = session.get('id')
    if 'api_key' in request.values:
        spac = Spac.all().filter('api_key =', request.values.get('api_key')).get()
        if spac:
            a = spac.key().name()
    if not a:
        abort(404)
    day = Day.get_day(y, m, d)
    try:
        by = float(request.values["by"])
    except:
        abort(500, "Raise by what?")
    try:
        value = float(request.values["value"])
    except:
        abort(500, "Bet on what value?")    
    try:
        Bet.raise_bet(a, day, by=by, value=value)
    except Exception, e:
        return "Error: could not raise bet. (%s)" % e
Exemplo n.º 4
0
def api_page():
    spac = session.get('id') and Spac.get_spac(session['id']) or None
    return render_template("api.html", spac=spac)
Exemplo n.º 5
0
def withdraw_funds():
    spac = Spac.get_spac(session['id'])
    try:
        spac.withdraw_funds()
    except Exception, e:
        return "Error: could not withdraw funds. (%s)" % e
Exemplo n.º 6
0
def profile():
    spac = Spac.get_spac(session['id'])
    return render_template('profile.html', spac=spac)
Exemplo n.º 7
0
def login(a):
    from google.appengine.api import users
    try:
        spac = Spac.get_spac(a, must_create=not users.is_current_user_admin())
    except Spac.AlreadyExists, e:
        return "This address is not available, please choose another one."
Exemplo n.º 8
0
def spac(a):
    spac = Spac.get_spac(a, must_exist=True)
    return render_template("spac.html", spac=spac)
Exemplo n.º 9
0
# --accounts
@app.route('/login/<a>')
def login(a):
    from google.appengine.api import users
    try:
        spac = Spac.get_spac(a, must_create=not users.is_current_user_admin())
    except Spac.AlreadyExists, e:
        return "This address is not available, please choose another one."

    session['id'] = spac.key().name()
    session['fund_addr'] = spac.address
    session['signup_status'] = 'complete'
    session.permanent = True
    
    if 'inviter' in session:
        inviter = Spac.get_spac(session['inviter'])
        spac.inviter = inviter
        spac.put()

    return redirect(request.values.get("next", "play"))
    
@app.route('/profile')
def profile():
    spac = Spac.get_spac(session['id'])
    return render_template('profile.html', spac=spac)

@app.route('/invited')
def invited():
    return render_template('invited.html')

@app.route('/verify_invite_code')