~ferruck/idekadoh

294635e9c8df348122c2d3042d9b87db3d0971d7 — Philipp Trommler 7 months ago 6cda2f8
Test entity relationships
2 files changed, 22 insertions(+), 4 deletions(-)

A idekadoh/templates/profile.html
M idekadoh/views/user.py
A idekadoh/templates/profile.html => idekadoh/templates/profile.html +7 -0
@@ 0,0 1,7 @@
{% extends "base.html" %}
{% block main %}
                <h1>{{ current_user.username }}</h1>
                <ul>{% for list in current_user.lists %}
                    <li>{{ list.name }}</li>{% endfor %}
                </ul>
{% endblock main %}

M idekadoh/views/user.py => idekadoh/views/user.py +15 -4
@@ 1,5 1,5 @@
from flask import Blueprint, flash, redirect, render_template, request, url_for
from flask_login import current_user, login_user, logout_user
from flask_login import current_user, login_required, login_user, logout_user
from flask_wtf import FlaskForm
from werkzeug.urls import url_parse
from wtforms import BooleanField, PasswordField, StringField, SubmitField


@@ 10,6 10,10 @@ user = Blueprint('user', __name__)

@user.route('/login', methods=['GET', 'POST'])
def login():
    """Logs the user in.

    Note that this should be the only function in this blueprint that has no
    login_required decoration!"""
    if current_user.is_authenticated:
        return redirect(url_for('home.index'))



@@ 30,13 34,20 @@ def login():

    return render_template('login.html', form=form)


@user.route('/logout')
@login_required
def logout():
    if current_user.is_authenticated:
        logout_user()

    logout_user()
    return redirect(url_for('home.index'))


@user.route('/profile')
@login_required
def profile():
    return render_template('profile.html')


class LoginForm(FlaskForm):
    username = StringField('Username')
    password = PasswordField('Password')