def refresh_cache(): if is_logged_in(): user_id = get_current_user_id() db = Database() user = db.get_user_by_id(user_id) for key in user.keys(): flask_session[key] = user[key] pass
def toggle_admin_for_user(user_id): db = Database() if is_logged_in() and db.is_user_id_administrator( flask_session['user_id']): user = db.get_user_by_id(user_id) role_id = user['role_id'] if role_id == db.get_administrator_role_id(): role_id = db.get_user_role_id() else: role_id = db.get_administrator_role_id() db.update_users_role(user_id, role_id) return redirect_to_referrer() else: flash( 'You must be logged in as an administrator to perform this operation.', 'danger') return redirect_to_referrer()