|
@ -37,6 +37,7 @@ app.config['LDAP_OPENLDAP'] = True |
|
|
app.config['LDAP_USER_OBJECT_FILTER'] = '(&(objectclass=posixAccount)(uid=%s))' |
|
|
app.config['LDAP_USER_OBJECT_FILTER'] = '(&(objectclass=posixAccount)(uid=%s))' |
|
|
|
|
|
|
|
|
# Login cookies |
|
|
# Login cookies |
|
|
|
|
|
app.config['SESSION_COOKIE_DOMAIN'] = os.environ.get('COOKIE_DOMAIN') |
|
|
app.config['REMEMBER_COOKIE_DOMAIN'] = os.environ.get('COOKIE_DOMAIN') |
|
|
app.config['REMEMBER_COOKIE_DOMAIN'] = os.environ.get('COOKIE_DOMAIN') |
|
|
|
|
|
|
|
|
db = SQLAlchemy(app) |
|
|
db = SQLAlchemy(app) |
|
@ -170,9 +171,11 @@ def game(): |
|
|
if (final_time - current_time).days > -1: |
|
|
if (final_time - current_time).days > -1: |
|
|
return render_template('final_countdown.j2', final_countdown = final_countdown_data) |
|
|
return render_template('final_countdown.j2', final_countdown = final_countdown_data) |
|
|
if countdown_data != None: |
|
|
if countdown_data != None: |
|
|
|
|
|
if current_user.is_authenticated: |
|
|
|
|
|
return render_template('games.j2', apps = games, search = search, account_url = account_url, description = game_description, countdown = countdown_data, game_list = generate_game_list(current_user.username)) |
|
|
return render_template('games.j2', apps = games, search = search, account_url = account_url, description = game_description, countdown = countdown_data) |
|
|
return render_template('games.j2', apps = games, search = search, account_url = account_url, description = game_description, countdown = countdown_data) |
|
|
if current_user.is_authenticated: |
|
|
if current_user.is_authenticated: |
|
|
return render_template('games.j2', apps = games, search = search, account_url = account_url, description = game_description, user = current_user.get_user_dict(), game_list = generate_game_list()) |
|
|
|
|
|
|
|
|
return render_template('games.j2', apps = games, search = search, account_url = account_url, description = game_description, game_list = generate_game_list(current_user.username)) |
|
|
return render_template('games.j2', apps = games, search = search, account_url = account_url, description = game_description) |
|
|
return render_template('games.j2', apps = games, search = search, account_url = account_url, description = game_description) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -180,7 +183,7 @@ def game(): |
|
|
def login(): |
|
|
def login(): |
|
|
if current_user.is_authenticated: |
|
|
if current_user.is_authenticated: |
|
|
flash('You are already logged in.') |
|
|
flash('You are already logged in.') |
|
|
return redirect(url_for('auth.home')) |
|
|
|
|
|
|
|
|
return redirect(url_for('index')) |
|
|
|
|
|
|
|
|
form = LoginForm(request.form) |
|
|
form = LoginForm(request.form) |
|
|
print(form) |
|
|
print(form) |
|
@ -225,17 +228,17 @@ def add_game(): |
|
|
if request.method == 'POST': |
|
|
if request.method == 'POST': |
|
|
game_title = request.form['game_title'] |
|
|
game_title = request.form['game_title'] |
|
|
game_link = request.form['game_link'] |
|
|
game_link = request.form['game_link'] |
|
|
conn = sqlite3.connect('config/games_in_progress.db') |
|
|
|
|
|
c = conn.cursor() |
|
|
|
|
|
|
|
|
games_conn = sqlite3.connect('config/games_in_progress.db') |
|
|
|
|
|
c = games_conn.cursor() |
|
|
|
|
|
|
|
|
if game_title is not None and len(game_title) > 0 and game_link is not None and len(game_link) > 0: |
|
|
if game_title is not None and len(game_title) > 0 and game_link is not None and len(game_link) > 0: |
|
|
c.execute("INSERT INTO games (user_id, game_title, game_link) VALUES (?, ?, ?)", (current_user.username, game_title, game_link,)) |
|
|
c.execute("INSERT INTO games (user_id, game_title, game_link) VALUES (?, ?, ?)", (current_user.username, game_title, game_link,)) |
|
|
conn.commit() |
|
|
|
|
|
conn.close() |
|
|
|
|
|
|
|
|
games_conn.commit() |
|
|
|
|
|
games_conn.close() |
|
|
|
|
|
|
|
|
return 'Success' |
|
|
return 'Success' |
|
|
conn.commit() |
|
|
|
|
|
conn.close() |
|
|
|
|
|
|
|
|
games_conn.commit() |
|
|
|
|
|
games_conn.close() |
|
|
return 'Error' |
|
|
return 'Error' |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -244,33 +247,29 @@ def add_game(): |
|
|
def delete_game(): |
|
|
def delete_game(): |
|
|
if request.method == 'POST': |
|
|
if request.method == 'POST': |
|
|
game_id = request.form['game_id'] |
|
|
game_id = request.form['game_id'] |
|
|
conn = sqlite3.connect('config/games_in_progress.db') |
|
|
|
|
|
c = conn.cursor() |
|
|
|
|
|
|
|
|
games_conn = sqlite3.connect('config/games_in_progress.db') |
|
|
|
|
|
c = games_conn.cursor() |
|
|
|
|
|
|
|
|
if game_id is not None and len(game_id) > 0: |
|
|
if game_id is not None and len(game_id) > 0: |
|
|
c.execute("DELETE FROM games WHERE id=? AND user_id=?", (game_id, session['user_id'],)) |
|
|
|
|
|
conn.commit() |
|
|
|
|
|
conn.close() |
|
|
|
|
|
|
|
|
c.execute("DELETE FROM games WHERE id=? AND user_id=?", (game_id, current_user.username,)) |
|
|
|
|
|
games_conn.commit() |
|
|
|
|
|
games_conn.close() |
|
|
|
|
|
|
|
|
return 'Success' |
|
|
return 'Success' |
|
|
conn.commit() |
|
|
|
|
|
conn.close() |
|
|
|
|
|
|
|
|
games_conn.commit() |
|
|
|
|
|
games_conn.close() |
|
|
return 'Error' |
|
|
return 'Error' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_game_list(): |
|
|
|
|
|
conn = sqlite3.connect('config/games_in_progress.db') |
|
|
|
|
|
c = conn.cursor() |
|
|
|
|
|
|
|
|
def generate_game_list(username): |
|
|
|
|
|
games_conn = sqlite3.connect('config/games_in_progress.db') |
|
|
|
|
|
c = games_conn.cursor() |
|
|
|
|
|
|
|
|
if current_user.is_authenticated: |
|
|
|
|
|
c.execute('SELECT * FROM games WHERE user_id=?', (current_user.username, )) |
|
|
|
|
|
rows = c.fetchall() |
|
|
|
|
|
conn.close() |
|
|
|
|
|
|
|
|
|
|
|
return rows |
|
|
|
|
|
|
|
|
c.execute('SELECT * FROM games WHERE user_id=?', (username, )) |
|
|
|
|
|
rows = c.fetchall() |
|
|
|
|
|
games_conn.close() |
|
|
|
|
|
|
|
|
conn.close() |
|
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
return rows |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/logout') |
|
|
@app.route('/logout') |
|
|