2022-02-08 11:26:20 +00:00
|
|
|
from app.auth.forms import LoginForm
|
|
|
|
from app.models import User
|
2020-02-19 15:36:55 +00:00
|
|
|
from flask import flash, redirect, render_template, url_for
|
2020-02-17 13:23:19 +00:00
|
|
|
from flask_login import login_required, login_user
|
2021-09-13 09:45:43 +00:00
|
|
|
from . import bp
|
2019-07-05 12:47:35 +00:00
|
|
|
|
2020-04-21 08:28:04 +00:00
|
|
|
|
2021-09-13 09:45:43 +00:00
|
|
|
@bp.route('/', methods=['GET', 'POST'])
|
2019-08-02 11:24:52 +00:00
|
|
|
def index():
|
2020-11-13 09:01:51 +00:00
|
|
|
form = LoginForm(prefix='login-form')
|
|
|
|
if form.validate_on_submit():
|
|
|
|
user = User.query.filter_by(username=form.user.data).first()
|
2020-02-20 08:45:38 +00:00
|
|
|
if user is None:
|
2020-11-13 09:01:51 +00:00
|
|
|
user = User.query.filter_by(email=form.user.data.lower()).first()
|
|
|
|
if user is not None and user.verify_password(form.password.data):
|
|
|
|
login_user(user, form.remember_me.data)
|
|
|
|
return redirect(url_for('.dashboard'))
|
2020-02-20 08:45:38 +00:00
|
|
|
flash('Invalid email/username or password.')
|
2020-11-13 09:01:51 +00:00
|
|
|
return render_template('main/index.html.j2', form=form, title='nopaque')
|
2019-08-02 11:24:52 +00:00
|
|
|
|
|
|
|
|
2021-11-18 11:09:15 +00:00
|
|
|
@bp.route('/faq')
|
|
|
|
def faq():
|
2022-02-08 11:26:20 +00:00
|
|
|
return render_template(
|
|
|
|
'main/faq.html.j2',
|
|
|
|
title='Frequently Asked Questions'
|
|
|
|
)
|
2020-10-12 11:28:19 +00:00
|
|
|
|
|
|
|
|
2021-09-13 09:45:43 +00:00
|
|
|
@bp.route('/dashboard')
|
2019-08-01 08:33:05 +00:00
|
|
|
@login_required
|
|
|
|
def dashboard():
|
2019-11-04 08:03:31 +00:00
|
|
|
return render_template('main/dashboard.html.j2', title='Dashboard')
|
2020-02-10 12:25:15 +00:00
|
|
|
|
|
|
|
|
2021-09-13 09:45:43 +00:00
|
|
|
@bp.route('/news')
|
2020-10-12 11:28:19 +00:00
|
|
|
def news():
|
|
|
|
return render_template('main/news.html.j2', title='News')
|
2020-03-18 13:44:15 +00:00
|
|
|
|
|
|
|
|
2021-09-13 09:45:43 +00:00
|
|
|
@bp.route('/privacy_policy')
|
2020-03-18 13:44:15 +00:00
|
|
|
def privacy_policy():
|
2022-02-08 11:26:20 +00:00
|
|
|
return render_template(
|
|
|
|
'main/privacy_policy.html.j2',
|
|
|
|
title='Privacy statement (GDPR)'
|
|
|
|
)
|
2020-07-03 09:17:47 +00:00
|
|
|
|
|
|
|
|
2021-09-13 09:45:43 +00:00
|
|
|
@bp.route('/terms_of_use')
|
2020-07-03 09:17:47 +00:00
|
|
|
def terms_of_use():
|
2020-11-13 09:01:51 +00:00
|
|
|
return render_template('main/terms_of_use.html.j2', title='Terms of Use')
|