mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-12-25 19:04:18 +00:00
61 lines
2.3 KiB
Python
61 lines
2.3 KiB
Python
from flask import flash, redirect, render_template, url_for
|
|
from flask_login import login_required, login_user
|
|
from . import main
|
|
from .forms import FeedbackForm
|
|
from .. import logger
|
|
from ..auth.forms import LoginForm
|
|
from ..models import User
|
|
|
|
@main.route('/', methods=['GET', 'POST'])
|
|
def index():
|
|
login_form = LoginForm(prefix='login-form')
|
|
if login_form.validate_on_submit():
|
|
user = User.query.filter_by(username=login_form.user.data).first()
|
|
if user is None:
|
|
user = User.query.filter_by(email=login_form.user.data).first()
|
|
if user is not None and user.verify_password(login_form.password.data):
|
|
login_user(user, login_form.remember_me.data)
|
|
return redirect(url_for('main.dashboard'))
|
|
flash('Invalid email/username or password.')
|
|
return render_template('main/index.html.j2', login_form=login_form,
|
|
title='nopaque')
|
|
|
|
|
|
@main.route('/dashboard')
|
|
@login_required
|
|
def dashboard():
|
|
return render_template('main/dashboard.html.j2', title='Dashboard')
|
|
|
|
|
|
@main.route('/feedback', methods=['GET', 'POST'])
|
|
@login_required
|
|
def feedback():
|
|
feedback_form = FeedbackForm(prefix='feedback-form')
|
|
if feedback_form.validate_on_submit():
|
|
logger.warning(feedback_form.email)
|
|
logger.warning(feedback_form.feedback)
|
|
logger.warning(feedback_form.like_range)
|
|
return render_template('main/feedback.html.j2',
|
|
feedback_form=feedback_form, title='Feedback')
|
|
|
|
|
|
@main.route('/poster', methods=['GET', 'POST'])
|
|
def poster():
|
|
login_form = LoginForm(prefix='login-form')
|
|
if login_form.validate_on_submit():
|
|
user = User.query.filter_by(username=login_form.user.data).first()
|
|
if user is None:
|
|
user = User.query.filter_by(email=login_form.user.data).first()
|
|
if user is not None and user.verify_password(login_form.password.data):
|
|
login_user(user, login_form.remember_me.data)
|
|
return redirect(url_for('main.dashboard'))
|
|
flash('Invalid email/username or password.')
|
|
return render_template('main/poster.html.j2', login_form=login_form,
|
|
title='Poster')
|
|
|
|
|
|
@main.route('/privacy_policy')
|
|
def privacy_policy():
|
|
return render_template('main/privacy_policy.html.j2',
|
|
title='Privacy policy')
|