|
|
@ -1,5 +1,5 @@ |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
'''Public section, including homepage and signup.''' |
|
|
|
"""Public section, including homepage and signup.""" |
|
|
|
from flask import (Blueprint, request, render_template, flash, url_for, |
|
|
|
from flask import (Blueprint, request, render_template, flash, url_for, |
|
|
|
redirect, session) |
|
|
|
redirect, session) |
|
|
|
from flask.ext.login import login_user, login_required, logout_user |
|
|
|
from flask.ext.login import login_user, login_required, logout_user |
|
|
@ -13,6 +13,7 @@ from {{cookiecutter.app_name}}.database import db |
|
|
|
|
|
|
|
|
|
|
|
blueprint = Blueprint('public', __name__, static_folder="../static") |
|
|
|
blueprint = Blueprint('public', __name__, static_folder="../static") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_manager.user_loader |
|
|
|
@login_manager.user_loader |
|
|
|
def load_user(id): |
|
|
|
def load_user(id): |
|
|
|
return User.get_by_id(int(id)) |
|
|
|
return User.get_by_id(int(id)) |
|
|
@ -32,6 +33,7 @@ def home(): |
|
|
|
flash_errors(form) |
|
|
|
flash_errors(form) |
|
|
|
return render_template("public/home.html", form=form) |
|
|
|
return render_template("public/home.html", form=form) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route('/logout/') |
|
|
|
@blueprint.route('/logout/') |
|
|
|
@login_required |
|
|
|
@login_required |
|
|
|
def logout(): |
|
|
|
def logout(): |
|
|
@ -39,6 +41,7 @@ def logout(): |
|
|
|
flash('You are logged out.', 'info') |
|
|
|
flash('You are logged out.', 'info') |
|
|
|
return redirect(url_for('public.home')) |
|
|
|
return redirect(url_for('public.home')) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route("/register/", methods=['GET', 'POST']) |
|
|
|
@blueprint.route("/register/", methods=['GET', 'POST']) |
|
|
|
def register(): |
|
|
|
def register(): |
|
|
|
form = RegisterForm(request.form, csrf_enabled=False) |
|
|
|
form = RegisterForm(request.form, csrf_enabled=False) |
|
|
@ -53,6 +56,7 @@ def register(): |
|
|
|
flash_errors(form) |
|
|
|
flash_errors(form) |
|
|
|
return render_template('public/register.html', form=form) |
|
|
|
return render_template('public/register.html', form=form) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route("/about/") |
|
|
|
@blueprint.route("/about/") |
|
|
|
def about(): |
|
|
|
def about(): |
|
|
|
form = LoginForm(request.form) |
|
|
|
form = LoginForm(request.form) |
|
|
|