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
|
2019-07-05 12:47:35 +00:00
|
|
|
from . import main
|
2020-03-02 13:05:31 +00:00
|
|
|
from .forms import FeedbackForm
|
2020-03-27 11:06:11 +00:00
|
|
|
from .. import logger
|
|
|
|
from ..auth.forms import LoginForm
|
|
|
|
from ..models import User
|
2019-07-05 12:47:35 +00:00
|
|
|
|
2020-04-21 08:28:04 +00:00
|
|
|
|
2020-02-17 13:23:19 +00:00
|
|
|
@main.route('/', methods=['GET', 'POST'])
|
2019-08-02 11:24:52 +00:00
|
|
|
def index():
|
2020-02-17 13:23:19 +00:00
|
|
|
login_form = LoginForm(prefix='login-form')
|
|
|
|
if login_form.validate_on_submit():
|
2020-02-20 08:45:38 +00:00
|
|
|
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()
|
2020-02-17 13:23:19 +00:00
|
|
|
if user is not None and user.verify_password(login_form.password.data):
|
|
|
|
login_user(user, login_form.remember_me.data)
|
2020-02-19 15:36:55 +00:00
|
|
|
return redirect(url_for('main.dashboard'))
|
2020-02-20 08:45:38 +00:00
|
|
|
flash('Invalid email/username or password.')
|
2020-02-17 13:23:19 +00:00
|
|
|
return render_template('main/index.html.j2', login_form=login_form,
|
|
|
|
title='nopaque')
|
2019-08-02 11:24:52 +00:00
|
|
|
|
|
|
|
|
2019-10-31 09:25:48 +00:00
|
|
|
@main.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
|
|
|
|
|
|
|
|
2020-03-02 13:05:31 +00:00
|
|
|
@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')
|
|
|
|
|
|
|
|
|
2020-02-27 08:55:58 +00:00
|
|
|
@main.route('/poster', methods=['GET', 'POST'])
|
2020-02-10 12:25:15 +00:00
|
|
|
def poster():
|
2020-02-25 13:53:33 +00:00
|
|
|
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.')
|
2020-02-27 08:55:58 +00:00
|
|
|
return render_template('main/poster.html.j2', login_form=login_form,
|
2020-02-27 09:15:04 +00:00
|
|
|
title='Poster')
|
2020-03-18 13:44:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
@main.route('/privacy_policy')
|
|
|
|
def privacy_policy():
|
|
|
|
return render_template('main/privacy_policy.html.j2',
|
|
|
|
title='Privacy policy')
|
2020-07-03 09:17:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
@main.route('/terms_of_use')
|
|
|
|
def terms_of_use():
|
|
|
|
return render_template('main/terms_of_use.html.j2', title='General Terms of Use of the platform nopaque') # noqa
|