Implimented some validation logic plus added flash messages
This commit is contained in:
parent
95edeb9987
commit
ea56c43eab
|
@ -14,7 +14,7 @@ TITLE = app.config['TITLE']
|
||||||
|
|
||||||
|
|
||||||
@app.route('/', methods=['GET', 'POST'])
|
@app.route('/', methods=['GET', 'POST'])
|
||||||
def root():
|
def home():
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
return render_template('index.html',
|
return render_template('index.html',
|
||||||
title=TITLE)
|
title=TITLE)
|
||||||
|
|
|
@ -13,12 +13,8 @@ TITLE = app.config['TITLE']
|
||||||
|
|
||||||
@app.route('/login', methods=['GET', 'POST'])
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
def login():
|
def login():
|
||||||
if request.method == 'GET':
|
|
||||||
_form = LoginForm()
|
_form = LoginForm()
|
||||||
|
|
||||||
return render_template('login.html',
|
return render_template('login.html',
|
||||||
title=TITLE,
|
title=TITLE,
|
||||||
form=_form)
|
form=_form)
|
||||||
|
|
||||||
return render_template('error.html',
|
|
||||||
title='Error!',
|
|
||||||
message='Must use GET request type...')
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# Python imports
|
# Python imports
|
||||||
|
|
||||||
# Lib imports
|
# Lib imports
|
||||||
from flask import request, render_template
|
from flask import request, render_template, url_for, redirect, flash
|
||||||
|
|
||||||
# App imports
|
# App imports
|
||||||
from core import app, db, RegisterForm
|
from core import app, db, RegisterForm
|
||||||
|
@ -13,12 +13,12 @@ TITLE = app.config['TITLE']
|
||||||
|
|
||||||
@app.route('/register', methods=['GET', 'POST'])
|
@app.route('/register', methods=['GET', 'POST'])
|
||||||
def register():
|
def register():
|
||||||
if request.method == 'GET':
|
|
||||||
_form = RegisterForm()
|
_form = RegisterForm()
|
||||||
|
|
||||||
|
if _form.validate_on_submit():
|
||||||
|
flash("Account created successfully!", "success")
|
||||||
|
return redirect(url_for("home"))
|
||||||
|
|
||||||
return render_template('register.html',
|
return render_template('register.html',
|
||||||
title=TITLE,
|
title=TITLE,
|
||||||
form=_form)
|
form=_form)
|
||||||
|
|
||||||
return render_template('error.html',
|
|
||||||
title='Error!',
|
|
||||||
message='Must use GET request type...')
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<div class="container">
|
<div class="container" style="position: fixed; bottom: 2em;">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col justify-content-center text-center">
|
<div class="col justify-content-center text-center">
|
||||||
<nav>
|
<nav>
|
||||||
<a href="mailto:"><i title="Send Us an Email" class="fas fa-envelope"></i></a>
|
<a href="mailto:"><i title="Send Us an Email" class="fas fa-envelope"></i></a>
|
||||||
<a href="#"><i title="Find Us on Twitter" class="fab fa-twitter"></i></a>
|
<a href="https://twitter.com/"><i title="Find Us on Twitter" class="fab fa-twitter"></i></a>
|
||||||
<a href="#"><i title="Find Us on LinkedIn" class="fab fa-linkedin"></i></a>
|
<a href="https://www.linkedin.com/"><i title="Find Us on LinkedIn" class="fab fa-linkedin"></i></a>
|
||||||
<br/>
|
<br/>
|
||||||
<i class="fas fa-map-marker-alt">US, Earth</i>
|
<i class="fas fa-map-marker-alt">US, Earth</i>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div class="navbar-brand justify-content-center text-center">
|
<div class="navbar-brand justify-content-center text-center">
|
||||||
<div class="site-branding">
|
<div class="site-branding">
|
||||||
<h1 class="site-title">
|
<h1 class="site-title">
|
||||||
<a href="{{ url_for('root') }}" title="TITLE" rel="home">
|
<a href="{{ url_for('home') }}" title="TITLE" rel="home">
|
||||||
Hello World!
|
Hello World!
|
||||||
</a>
|
</a>
|
||||||
</h1>
|
</h1>
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
<!-- Links -->
|
<!-- Links -->
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{{ url_for('root') }}">
|
<a class="nav-link" href="{{ url_for('home') }}">
|
||||||
<i class="fas fa-home"></i> Home</a>
|
<i class="fas fa-home"></i> Home</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
|
|
||||||
{% block body_header_additional %}
|
{% block body_header_additional %}
|
||||||
<h1 style=" position: fixed; top: 0em;">Header</h1>
|
|
||||||
{% endblock body_header_additional %}
|
{% endblock body_header_additional %}
|
||||||
|
|
||||||
{% block body_content %}
|
{% block body_content %}
|
||||||
|
@ -19,7 +18,6 @@
|
||||||
|
|
||||||
|
|
||||||
{% block body_footer_additional %}
|
{% block body_footer_additional %}
|
||||||
<h1 style=" position: fixed; bottom: 0em;">Footer</h1>
|
|
||||||
{% endblock body_footer_additional %}
|
{% endblock body_footer_additional %}
|
||||||
|
|
||||||
{% block body_scripts_additional %}
|
{% block body_scripts_additional %}
|
||||||
|
|
|
@ -30,6 +30,17 @@
|
||||||
{% endblock header_css_additional %}
|
{% endblock header_css_additional %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
<!-- System flashed messages! -->
|
||||||
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||||
|
{% if messages %}
|
||||||
|
<div class=flashes>
|
||||||
|
{% for category, message in messages %}
|
||||||
|
<li class="alert alert-{{ category }}">{{ message }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
{% block header_scripts %}
|
{% block header_scripts %}
|
||||||
{% block header_scripts_additional %}
|
{% block header_scripts_additional %}
|
||||||
{% endblock header_scripts_additional %}
|
{% endblock header_scripts_additional %}
|
||||||
|
|
|
@ -15,11 +15,30 @@
|
||||||
<a href="/register">Register</a>
|
<a href="/register">Register</a>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ form.username.label(class="form-control-label") }}
|
{{ form.username.label(class="form-control-label") }}
|
||||||
|
|
||||||
|
{% if form.username.errors %}
|
||||||
|
{{ form.username(class="form-control form-control-sm is-invalid", autocomplete="off") }}
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
{% for error in form.username.errors %}
|
||||||
|
<span class="">{{ error }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
{{ form.username(class="form-control form-control-sm", autocomplete="off") }}
|
{{ form.username(class="form-control form-control-sm", autocomplete="off") }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ form.password.label(class="form-control-label") }}
|
{{ form.password.label(class="form-control-label") }}
|
||||||
|
|
||||||
|
{% if form.email.errors %}
|
||||||
|
{{ form.email(class="form-control form-control-sm is-invalid", autocomplete="off") }}
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
{% for error in form.email.errors %}
|
||||||
|
<span class="">{{ error }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
{{ form.password(class="form-control form-control-sm", autocomplete="off") }}
|
{{ form.password(class="form-control form-control-sm", autocomplete="off") }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="form-group justify-content-right text-right">
|
<div class="form-group justify-content-right text-right">
|
||||||
|
@ -36,8 +55,4 @@
|
||||||
{% endblock body_footer_additional %}
|
{% endblock body_footer_additional %}
|
||||||
|
|
||||||
{% block body_scripts_additional %}
|
{% block body_scripts_additional %}
|
||||||
<script src="{{ url_for('static', filename='js/ui-logic.js')}}"></script>
|
|
||||||
<script src="{{ url_for('static', filename='js/post-ajax.js')}}"></script>
|
|
||||||
<script src="{{ url_for('static', filename='js/ajax.js')}}"></script>
|
|
||||||
<script src="{{ url_for('static', filename='js/events.js')}}"></script>
|
|
||||||
{% endblock body_scripts_additional %}
|
{% endblock body_scripts_additional %}
|
||||||
|
|
|
@ -14,19 +14,56 @@
|
||||||
<legend class="border-bottom mb-4">Create Account</legend>
|
<legend class="border-bottom mb-4">Create Account</legend>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ form.username.label(class="form-control-label") }}
|
{{ form.username.label(class="form-control-label") }}
|
||||||
|
|
||||||
|
{% if form.username.errors %}
|
||||||
|
{{ form.username(class="form-control form-control-sm is-invalid", autocomplete="off") }}
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
{% for error in form.username.errors %}
|
||||||
|
<span class="">{{ error }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
{{ form.username(class="form-control form-control-sm", autocomplete="off") }}
|
{{ form.username(class="form-control form-control-sm", autocomplete="off") }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ form.email.label(class="form-control-label") }}
|
{{ form.email.label(class="form-control-label") }}
|
||||||
|
|
||||||
|
{% if form.email.errors %}
|
||||||
|
{{ form.email(class="form-control form-control-sm is-invalid", autocomplete="off") }}
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
{% for error in form.email.errors %}
|
||||||
|
<span class="">{{ error }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
{{ form.email(class="form-control form-control-sm", autocomplete="off") }}
|
{{ form.email(class="form-control form-control-sm", autocomplete="off") }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ form.password.label(class="form-control-label") }}
|
{{ form.password.label(class="form-control-label") }}
|
||||||
|
|
||||||
|
{% if form.password.errors %}
|
||||||
|
{{ form.password(class="form-control form-control-sm is-invalid", autocomplete="off") }}
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
{% for error in form.password.errors %}
|
||||||
|
<span class="">{{ error }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
{{ form.password(class="form-control form-control-sm", autocomplete="off") }}
|
{{ form.password(class="form-control form-control-sm", autocomplete="off") }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
{{ form.confirm_password.label(class="form-control-label") }}
|
{{ form.confirm_password.label(class="form-control-label") }}
|
||||||
|
|
||||||
|
{% if form.confirm_password.errors %}
|
||||||
|
{{ form.confirm_password(class="form-control form-control-sm is-invalid", autocomplete="off") }}
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
{% for error in form.confirm_password.errors %}
|
||||||
|
<span class="">{{ error }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
{{ form.confirm_password(class="form-control form-control-sm", autocomplete="off") }}
|
{{ form.confirm_password(class="form-control form-control-sm", autocomplete="off") }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div class="form-group justify-content-right text-right">
|
<div class="form-group justify-content-right text-right">
|
||||||
|
@ -46,8 +83,4 @@
|
||||||
{% endblock body_footer_additional %}
|
{% endblock body_footer_additional %}
|
||||||
|
|
||||||
{% block body_scripts_additional %}
|
{% block body_scripts_additional %}
|
||||||
<script src="{{ url_for('static', filename='js/ui-logic.js')}}"></script>
|
|
||||||
<script src="{{ url_for('static', filename='js/post-ajax.js')}}"></script>
|
|
||||||
<script src="{{ url_for('static', filename='js/ajax.js')}}"></script>
|
|
||||||
<script src="{{ url_for('static', filename='js/events.js')}}"></script>
|
|
||||||
{% endblock body_scripts_additional %}
|
{% endblock body_scripts_additional %}
|
||||||
|
|
Loading…
Reference in New Issue