Token count in menu

This commit is contained in:
Jeremy Zhang 2017-08-14 05:43:25 +00:00
parent 0d87e11e3e
commit fc05f3dda2
3 changed files with 8 additions and 5 deletions

View File

@ -41,6 +41,9 @@ def callback():
session['username'] = user['username']
session['discriminator'] = user['discriminator']
session['avatar'] = generate_avatar_url(user['id'], user['avatar'])
session["tokens"] = get_titan_token(session["user_id"])
if session["tokens"] == -1:
session["tokens"] = 0
if session["redirect"]:
redir = session["redirect"]
session['redirect'] = None
@ -72,10 +75,7 @@ def dashboard():
css_list = None
if cosmetics and cosmetics.css:
css_list = db.session.query(UserCSS).filter(UserCSS.user_id == session['user_id']).all()
tokens = get_titan_token(session["user_id"])
if tokens == -1:
tokens = 0
return render_template("dashboard.html.j2", servers=guilds, icon_generate=generate_guild_icon_url, cosmetics=cosmetics, css_list=css_list, tokens=tokens)
return render_template("dashboard.html.j2", servers=guilds, icon_generate=generate_guild_icon_url, cosmetics=cosmetics, css_list=css_list)
@user.route("/custom_css/new", methods=["GET"])
@discord_users_only()
@ -383,6 +383,7 @@ def donate_confirm():
tokens = int(amount * 100)
action = "PAYPAL {}".format(trans_id)
set_titan_token(session["user_id"], tokens, action)
session["tokens"] = get_titan_token(session["user_id"])
return redirect(url_for('user.donate_thanks', transaction=trans_id))
else:
return redirect(url_for('index'))

View File

@ -68,7 +68,7 @@
<div class="card-panel indigo lighten-5 z-depth-3 hoverable black-text">
<h4>Donations!</h4>
<p class="flow-text">Would you like to support the Titan Embeds project?</p>
<p>You currently have <strong>{{ tokens }}</strong> Titan Tokens.</p>
<p>You currently have <strong>{{ session["tokens"] }}</strong> Titan Tokens.</p>
<a class="waves-effect waves-light btn" href="{{ url_for('user.donate_get') }}">Donate!!</a>
</div>
</div>

View File

@ -28,6 +28,8 @@
{% if session['unauthenticated'] is defined and not session['unauthenticated'] %}
<ul id="menu_dropdown" class="dropdown-content">
<li><a href="{{ url_for('user.dashboard') }}">Dashboard</a></li>
<li class="divider"></li>
<li><a href="{{ url_for('user.donate_get') }}"><i class="material-icons">monetization_on</i></nbr>{{ session["tokens"] }}</a></li>
{% if session['user_id'] is defined and session['user_id'] in devs %}
<li class="divider"></li>
<li><a href="{{ url_for('admin.index') }}">Admin</a></li>