def settings(): if not current_user.is_authenticated: flash('Please Login to continue..') return redirect('/login') user = current_user form = SettingsForm() form.name.render_kw = {'placeholder': user.name} form.username.render_kw = {'placeholder': user.username} form.email.render_kw = {'placeholder': user.email} if request.method == 'GET': if request.path == '/settings/delete': return render_template('confirm_remove.html') return render_template('settings.html', user=user, form=form) elif request.method == 'POST': if request.path == '/settings/delete': Quiz.remove_player(user.username) flash('Sorry to see you go :(') flash('You will be missed..') return redirect('/') if form.validate(): if form.name.data.strip() and user.name != form.name.data.strip(): user.name = form.name.data.strip() form.name.render_kw = {'placeholder': form.name.data} user.update_user_info() flash('Name Updated Successfully!') if form.username.data.strip( ) and user.username != form.username.data.strip(): user.username = form.username.data.strip().lower() form.username.render_kw = { 'placeholder': form.username.data.strip().lower() } user.update_user_info() flash('Username Updated Successfully!') if form.email.data.strip( ) and user.email != form.email.data.strip(): user.email = form.email.data.strip().lower() form.email.render_kw = { 'placeholder': form.email.data.strip().lower() } user.update_user_info() flash('Email Address Updated Successfully!') if form.password.data and len( form.password.data) in [i for i in range(8, 17)]: user.password = form.password.data user.update_user_info(settings=True) flash('Password Updated Successfully!') form.email.data = form.name.data = form.username.data = "" return render_template('settings.html', user=user, form=form) return render_template('404.html')
def player_dashboard(pid=None): if current_user.is_authenticated and current_user.is_admin: players = User.get_all_users() if request.path == '/admin/dashboard/Players/view': return render_template('view_players.html', players=players) elif pid and len(pid) < 100 and (pid.replace('-', '').isalnum() or pid.replace('_', '').isalnum()): if not User.get_user_info(username=pid): flash('Can\'t find player') return redirect('/admin/dashboard/Players/view') if request.method == "POST": Quiz.remove_player(pid) flash('Player Removed!') return redirect('/admin/dashboard/Players/view') return render_template('remove_player.html', players=players) return render_template('view_players.html', players=players) return render_template('404.html')