def chatroom(name): """ Actual chat room handling function but not complete """ if get_user_name(): if check_chatroom(name): return render_template('chat.html', \ room=name,username=session['user_name']) else: return redirect(url_for('register'), username=session['user_name']) else: session['next'] = url_for('chatroom', name=name) return redirect(url_for('login'))
def register(): if get_user_name(): form = RegisterChatRoom(request.form) if request.method == 'POST' and form.validate(): chatroom_name = form.chatroom_name.data if not check_chatroom(chatroom_name): if add_chatroom(chatroom_name, session['user_name']): flash(chatroom_name + " successfully added ") return render_template('register.html', form=form, \ chatrooms=get_all_chatroom(), username=get_user_name()) return render_template('register.html', form=form, \ chatrooms=get_all_chatroom(), username=get_user_name()) else: session['next'] = url_for('register') return redirect(url_for('login'))