2020-02-19 15:36:55 +00:00
|
|
|
from flask import flash, redirect, render_template, url_for
|
2023-03-13 15:22:42 +00:00
|
|
|
from flask_breadcrumbs import register_breadcrumb
|
2022-12-19 11:46:18 +00:00
|
|
|
from flask_login import current_user, login_required, login_user
|
2022-09-02 11:07:30 +00:00
|
|
|
from app.auth.forms import LoginForm
|
2023-01-31 07:59:42 +00:00
|
|
|
from app.models import Corpus, User
|
2023-05-05 06:41:14 +00:00
|
|
|
from sqlalchemy import or_
|
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
|
|
|
|
2023-05-11 14:33:21 +00:00
|
|
|
@bp.route('/', methods=['GET', 'POST'])
|
2023-03-13 15:22:42 +00:00
|
|
|
@register_breadcrumb(bp, '.', '<i class="material-icons">home</i>')
|
2019-08-02 11:24:52 +00:00
|
|
|
def index():
|
2023-03-29 07:25:08 +00:00
|
|
|
form = LoginForm()
|
2020-11-13 09:01:51 +00:00
|
|
|
if form.validate_on_submit():
|
2022-09-02 11:07:30 +00: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):
|
2020-11-13 09:01:51 +00:00
|
|
|
login_user(user, form.remember_me.data)
|
2022-09-02 11:07:30 +00:00
|
|
|
flash('You have been logged in')
|
2020-11-13 09:01:51 +00:00
|
|
|
return redirect(url_for('.dashboard'))
|
2022-09-02 11:07:30 +00:00
|
|
|
flash('Invalid email/username or password', category='error')
|
|
|
|
redirect(url_for('.index'))
|
2023-03-28 12:19:37 +00:00
|
|
|
return render_template(
|
|
|
|
'main/index.html.j2',
|
|
|
|
title='nopaque',
|
|
|
|
form=form
|
|
|
|
)
|
2019-08-02 11:24:52 +00:00
|
|
|
|
|
|
|
|
2021-11-18 11:09:15 +00:00
|
|
|
@bp.route('/faq')
|
2023-03-13 15:22:42 +00:00
|
|
|
@register_breadcrumb(bp, '.faq', 'Frequently Asked Questions')
|
2021-11-18 11:09:15 +00:00
|
|
|
def faq():
|
2023-03-28 12:19:37 +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')
|
2023-03-14 10:13:35 +00:00
|
|
|
@register_breadcrumb(bp, '.dashboard', '<i class="material-icons left">dashboard</i>Dashboard')
|
2019-08-01 08:33:05 +00:00
|
|
|
@login_required
|
|
|
|
def dashboard():
|
2023-03-28 12:19:37 +00:00
|
|
|
return render_template(
|
|
|
|
'main/dashboard.html.j2',
|
|
|
|
title='Dashboard'
|
|
|
|
)
|
2020-02-10 12:25:15 +00:00
|
|
|
|
|
|
|
|
2023-03-16 09:31:58 +00:00
|
|
|
# @bp.route('/user_manual')
|
|
|
|
# @register_breadcrumb(bp, '.user_manual', '<i class="material-icons left">help</i>User manual')
|
|
|
|
# def user_manual():
|
|
|
|
# return render_template('main/user_manual.html.j2', title='User manual')
|
2022-05-17 13:31:05 +00:00
|
|
|
|
|
|
|
|
2021-09-13 09:45:43 +00:00
|
|
|
@bp.route('/news')
|
2023-03-14 13:21:23 +00:00
|
|
|
@register_breadcrumb(bp, '.news', '<i class="material-icons left">email</i>News')
|
2020-10-12 11:28:19 +00:00
|
|
|
def news():
|
2023-03-28 12:19:37 +00:00
|
|
|
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')
|
2023-03-13 15:22:42 +00:00
|
|
|
@register_breadcrumb(bp, '.privacy_policy', 'Private statement (GDPR)')
|
2020-03-18 13:44:15 +00:00
|
|
|
def privacy_policy():
|
2023-03-28 12:19:37 +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')
|
2023-03-13 15:22:42 +00:00
|
|
|
@register_breadcrumb(bp, '.terms_of_use', 'Terms of Use')
|
2020-07-03 09:17:47 +00:00
|
|
|
def terms_of_use():
|
2023-03-28 12:19:37 +00:00
|
|
|
return render_template(
|
|
|
|
'main/terms_of_use.html.j2',
|
|
|
|
title='Terms of Use'
|
|
|
|
)
|
2023-03-01 13:09:15 +00:00
|
|
|
|
2023-03-10 11:07:18 +00:00
|
|
|
|
2023-10-24 14:11:08 +00:00
|
|
|
@bp.route('/social-area')
|
|
|
|
@register_breadcrumb(bp, '.social_area', '<i class="material-icons left">group</i>Social Area')
|
|
|
|
@login_required
|
|
|
|
def social_area():
|
2023-10-25 14:21:30 +00:00
|
|
|
print('test')
|
2023-10-24 14:11:08 +00:00
|
|
|
corpora = Corpus.query.filter(Corpus.is_public == True, Corpus.user != current_user).all()
|
2023-10-25 14:21:30 +00:00
|
|
|
print(corpora)
|
2023-10-24 14:11:08 +00:00
|
|
|
users = User.query.filter(User.is_public == True, User.id != current_user.id).all()
|
|
|
|
return render_template(
|
|
|
|
'main/social_area.html.j2',
|
|
|
|
title='Social Area',
|
|
|
|
corpora=corpora,
|
|
|
|
users=users
|
|
|
|
)
|