예제 #1
0
def login():
    if is_authenticated():
        return redirect(url_for("home"))

    form = LoginForm(request.form)
    if request.method == 'POST' and form.validate():
        user.user_login(form)
        return redirect(url_for("home"))
    return render_template('login.html', form=form)
예제 #2
0
파일: upvote.py 프로젝트: charulagrl/reddit
def upvote(topic_id):
    if request_wants_html():
        if not is_authenticated():
            return redirect(url_for('login'))

        if request.method == 'GET':
            response = create_upvote_html(topic_id)

            return redirect(url_for('get_topic', topic_id=topic_id))
    else:
        if request.method == 'POST':
            response = create_upvote_json(request.json, topic_id)
            return response
예제 #3
0
파일: topic.py 프로젝트: charulagrl/reddit
def create_topic():
    if request_wants_html():
        if not is_authenticated():
            return redirect(url_for('login'))

        form = TopicForm(request.form)
        if request.method == 'POST' and form.validate():
            new_topic = topic.create_topic_html(form)
            return render_template("topic_created.html", topic=new_topic)

        return render_template('topic.html', form=form)
    else:
        if request.method == 'POST':
            return topic.create_topic_json(request.json)
예제 #4
0
def logout():
    if not is_authenticated():
        return redirect(url_for('login'))

    user.user_logout()
    return redirect(url_for('login'))