ensure that curiouscat avi is always loaded
This commit is contained in:
parent
79cb6ffa54
commit
6f40492a35
1 changed files with 8 additions and 6 deletions
14
web.py
14
web.py
|
@ -55,12 +55,14 @@ def home():
|
||||||
if 'acct' in session:
|
if 'acct' in session:
|
||||||
if 'cc' not in session:
|
if 'cc' not in session:
|
||||||
session['cc'] = "None"
|
session['cc'] = "None"
|
||||||
if session['cc'] == "None":
|
if session['cc'] == "None" or 'ccavi' not in session:
|
||||||
#every time home is rendered without cc being set
|
#every time home is rendered without cc being set
|
||||||
c.execute("SELECT cc FROM `data` WHERE client_id LIKE %s AND instance LIKE %s", (session['client_id'], session['instance']))
|
c.execute("SELECT cc, ccavi FROM `data` WHERE client_id LIKE %s AND instance LIKE %s", (session['client_id'], session['instance']))
|
||||||
cc = c.fetchone()[0]
|
cc = c.fetchone()
|
||||||
if cc != '':
|
if cc[0] != '':
|
||||||
session['cc'] = cc
|
session['cc'] = cc[0]
|
||||||
|
session['ccavi'] = cc[1]
|
||||||
|
|
||||||
|
|
||||||
if 'last_avi_update' not in session or session['last_avi_update'] + (24 * 60 * 60) < time.time():
|
if 'last_avi_update' not in session or session['last_avi_update'] + (24 * 60 * 60) < time.time():
|
||||||
#avatars haven't been updated for over 24 hours, update them now
|
#avatars haven't been updated for over 24 hours, update them now
|
||||||
|
@ -75,7 +77,7 @@ def home():
|
||||||
c.execute("UPDATE data SET avi = %s, ccavi = %s WHERE client_id LIKE %s AND instance LIKE %s", (session['avi'], session['ccavi'], session['client_id'], session['instance']))
|
c.execute("UPDATE data SET avi = %s, ccavi = %s WHERE client_id LIKE %s AND instance LIKE %s", (session['avi'], session['ccavi'], session['client_id'], session['instance']))
|
||||||
else:
|
else:
|
||||||
c.execute("UPDATE data SET avi = %s WHERE client_id LIKE %s AND instance LIKE %s", (session['avi'], session['client_id'], session['instance']))
|
c.execute("UPDATE data SET avi = %s WHERE client_id LIKE %s AND instance LIKE %s", (session['avi'], session['client_id'], session['instance']))
|
||||||
return render_template("home.html")
|
return render_template("home.html", mabg="background-image:url('{}')".format(session['avi']), ccbg="background-image:url('{}')".format(session['ccavi']))
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('main'))
|
return redirect(url_for('main'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue