示例#1
0
def login():
    if current_user.is_authenticated and login_fresh():
        return redirect(url_for("main.home"))

    form = LoginForm()
    picture = generate_header_picture()

    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data.lower()).first()

        if not form.validate_email(form.email):
            flash("Email does not exist. Please try again", "danger")
        elif not bcrypt.check_password_hash(user.password, form.password.data):
            flash("Incorrect password. Please try again", "danger")
        else:
            login_user(user, remember=form.remember.data)
            next_page = request.args.get('next')

            if next_page:
                return redirect(next_page)
            else:
                return redirect(url_for("main.home"))

    return render_template("login.html",
                           form=form,
                           picture=picture,
                           current_login_type="personal account",
                           needed_login_type="company")
示例#2
0
def show_companies():
	picture = generate_header_picture()
	page = request.args.get("page", 1, type=int)
	companies = Company.query.paginate(page=page, per_page=Constants.COMPANIES_ON_SHOW_COMPANIES_PAGE)
	prev_page = url_for('companies.show_companies', page=companies.prev_num)
	next_page = url_for('companies.show_companies', page=companies.next_num)
	return render_template("show_companies.html", picture=picture, paginate=True,
							companies=companies, prev_page=prev_page, next_page=next_page)
示例#3
0
def error_400(error):
	picture = generate_header_picture()
	return render_template('errors/400.html', picture=picture), Constants.BAD_REQUEST_ERROR_PAGE
示例#4
0
def error_500(error):
	picture = generate_header_picture()
	return render_template('errors/500.html', picture=picture), Constants.INTERNAL_SERVER_ERROR_PAGE
示例#5
0
def maintenance(error):
	picture = generate_header_picture()
	return render_template('errors/maintenance.html', picture=picture), Constants.MAINTENANCE_PAGE
示例#6
0
def error_404(error):
	picture = generate_header_picture()
	return render_template('errors/404.html', picture=picture), Constants.PAGE_NOT_FOUND_ERROR_PAGE
示例#7
0
def error_403(error):
	picture = generate_header_picture()
	return render_template('errors/403.html', picture=picture), Constants.FORBIDDEN_PAGE_ERROR_PAGE
示例#8
0
def coming_soon(error):
	picture = generate_header_picture()
	return render_template('errors/coming_soon.html', picture=picture), Constants.COMING_SOON_PAGE
示例#9
0
def home():
    picture = generate_header_picture()
    articles = Article.query.order_by(Article.views.desc()).limit(
        Constants.ARTICLES_ON_HOME_PAGE).all()
    return render_template("index.html", articles=articles, picture=picture)
示例#10
0
def about():
    picture = generate_header_picture()
    return render_template("about.html", picture=picture)