86 lines
2.0 KiB
Python
Raw Normal View History

2020-02-19 16:36:55 +01:00
from flask import flash, redirect, render_template, url_for
2022-12-19 12:46:18 +01:00
from flask_login import current_user, login_required, login_user
2024-09-30 13:30:13 +02:00
from app.blueprints.auth.forms import LoginForm
from app.models import Corpus, User
from . import bp
2020-04-21 10:28:04 +02:00
2023-05-11 16:33:21 +02:00
@bp.route('/', methods=['GET', 'POST'])
2019-08-02 13:24:52 +02:00
def index():
form = LoginForm()
if form.validate_on_submit():
2022-09-02 13:07:30 +02:00
user = User.query.filter((User.email == form.user.data.lower()) | (User.username == form.user.data)).first()
if user and user.verify_password(form.password.data):
login_user(user, form.remember_me.data)
2022-09-02 13:07:30 +02:00
flash('You have been logged in')
return redirect(url_for('.dashboard'))
2022-09-02 13:07:30 +02:00
flash('Invalid email/username or password', category='error')
redirect(url_for('.index'))
2023-03-28 14:19:37 +02:00
return render_template(
'main/index.html.j2',
title='nopaque',
form=form
)
2019-08-02 13:24:52 +02:00
2021-11-18 12:09:15 +01:00
@bp.route('/faq')
def faq():
2023-03-28 14:19:37 +02:00
return render_template(
'main/faq.html.j2',
title='Frequently Asked Questions'
)
2020-10-12 13:28:19 +02:00
@bp.route('/dashboard')
2019-08-01 10:33:05 +02:00
@login_required
def dashboard():
2023-03-28 14:19:37 +02:00
return render_template(
'main/dashboard.html.j2',
title='Dashboard'
)
2020-02-10 13:25:15 +01:00
2024-05-21 10:29:12 +02:00
@bp.route('/manual')
def manual():
return render_template(
'main/manual.html.j2',
title='Manual'
)
@bp.route('/news')
2020-10-12 13:28:19 +02:00
def news():
2023-03-28 14:19:37 +02:00
return render_template(
'main/news.html.j2',
title='News'
)
2020-03-18 14:44:15 +01:00
@bp.route('/privacy_policy')
2020-03-18 14:44:15 +01:00
def privacy_policy():
2023-03-28 14:19:37 +02:00
return render_template(
'main/privacy_policy.html.j2',
title='Privacy statement (GDPR)'
)
2020-07-03 11:17:47 +02:00
@bp.route('/terms_of_use')
2020-07-03 11:17:47 +02:00
def terms_of_use():
2023-03-28 14:19:37 +02:00
return render_template(
'main/terms_of_use.html.j2',
title='Terms of Use'
)
2023-03-10 12:07:18 +01:00
2024-11-15 15:59:08 +01:00
@bp.route('/social')
@login_required
2024-11-15 15:59:08 +01:00
def social():
corpora = Corpus.query.filter(Corpus.is_public == True, Corpus.user != current_user).all()
users = User.query.filter(User.is_public == True, User.id != current_user.id).all()
return render_template(
2024-11-15 15:59:08 +01:00
'main/social.html.j2',
title='Social',
corpora=corpora,
users=users
)