new registration form
This commit is contained in:
parent
f934793e39
commit
dbd6ad0dd2
|
@ -22,17 +22,21 @@ class DevelopmentConfig(Config):
|
|||
SQLALCHEMY_DATABASE_URI = os.environ.get('DEV_DATABASE_URL') or \
|
||||
('mysql://root:Polo1043@localhost/dashDev')
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = True
|
||||
WTF_CSRF_ENABLED = True
|
||||
SECRET_KEY = 'you-will-never-guess'
|
||||
|
||||
class TestingConfig(Config):
|
||||
TESTING = True
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get('TEST_DATABASE_URL') or \
|
||||
('mysql://root:Polo1043@localhost/dashTest')
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = True
|
||||
|
||||
class ProductionConfig(Config):
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
|
||||
('mysql://root:Polo1043@localhost/dash')
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
WTF_CSRF_ENABLED = True
|
||||
SECRET_KEY = 'you-will-never-guess'
|
||||
|
||||
config = {
|
||||
'development': DevelopmentConfig,
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,7 +1,8 @@
|
|||
from flask_wtf import Form
|
||||
|
||||
from wtforms import StringField, PasswordField, BooleanField, SubmitField
|
||||
from wtforms.validators import Required, Length, Email
|
||||
from wtforms.validators import Required, Length, Email, Regexp, EqualTo
|
||||
from wtforms import ValidationError
|
||||
from ..models import User
|
||||
|
||||
class LoginForm(Form):
|
||||
email = StringField('Email', validators=[Required(), Length(1, 128),
|
||||
|
@ -9,4 +10,23 @@ class LoginForm(Form):
|
|||
password = PasswordField('Password', validators=[Required()])
|
||||
remember_me = BooleanField('Keep me logged in')
|
||||
submit = SubmitField('Log In')
|
||||
|
||||
|
||||
class RegistrationForm(Form):
|
||||
email = StringField('Email', validators=[Required(), Length(1, 128),
|
||||
Email()])
|
||||
username = StringField('Username', validators=[
|
||||
Required(), Length(1, 64), Regexp('^[A-Za-z][A-Za-z0-9_.]*$', 0,
|
||||
'Usernames must have only letters, '
|
||||
'numbers, dots or underscores')])
|
||||
password = PasswordField('Password', validators=[
|
||||
Required(), EqualTo('password2', message='Passwords must match.')])
|
||||
password2 = PasswordField('Confirm password', validators=[Required()])
|
||||
submit = SubmitField('Register')
|
||||
|
||||
def validate_email(self, field):
|
||||
if User.query.filter_by(email=field.data).first():
|
||||
raise ValidationError('Email already registered.')
|
||||
|
||||
def validate_username(self, field):
|
||||
if User.query.filter_by(username=field.data).first():
|
||||
raise ValidationError('Username already in use.')
|
Binary file not shown.
|
@ -2,7 +2,7 @@ from flask import render_template, redirect, request, url_for, flash
|
|||
from flask_login import login_user, logout_user, login_required
|
||||
from . import auth
|
||||
from ..models import User
|
||||
from .forms import LoginForm
|
||||
from .forms import LoginForm, RegistrationForm
|
||||
|
||||
|
||||
@auth.route('/login', methods=['GET', 'POST'])
|
||||
|
@ -21,4 +21,9 @@ def login():
|
|||
def logout():
|
||||
logout_user()
|
||||
flash('You have been logged out.')
|
||||
return redirect(url_for('main.index'))
|
||||
return redirect(url_for('main.index'))
|
||||
|
||||
@auth.route('/register')
|
||||
def register():
|
||||
form = RegistrationForm()
|
||||
return render_template('auth/register.html', form=form)
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,76 @@
|
|||
{% extends "adminlte/base_without_nav.html" %}
|
||||
|
||||
{% block title %}Register{% endblock %}
|
||||
{% block description %}Register a new account{% endblock %}
|
||||
{% block bodytag %}register-page{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
|
||||
<div class="register-box">
|
||||
<div class="register-logo">
|
||||
<a href="#"><b>-</b>stack</a>
|
||||
</div>
|
||||
|
||||
<div class="register-box-body">
|
||||
<p class="login-box-msg">Register a new account</p>
|
||||
{# Display errors (if there are any). #}
|
||||
{% with messages = get_flashed_messages() %}
|
||||
{% if messages %}
|
||||
<ul>
|
||||
{% for message in messages %}
|
||||
<li>{{ message }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{# Render the login form. #}
|
||||
<form action="" method="post" name="register">
|
||||
{{ form.hidden_tag() }}
|
||||
<div class="form-group has-feedback">
|
||||
<input type="text" class="form-control" placeholder="Full name">
|
||||
<span class="glyphicon glyphicon-user form-control-feedback"></span>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<input type="email" class="form-control" placeholder="Email">
|
||||
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<input type="password" class="form-control" placeholder="Password">
|
||||
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
|
||||
</div>
|
||||
<div class="form-group has-feedback">
|
||||
<input type="password" class="form-control" placeholder="Retype password">
|
||||
<span class="glyphicon glyphicon-log-in form-control-feedback"></span>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-xs-8 col-xs-offset-0">
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox"> I agree to the <a href="#">terms</a>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
<div class="col-xs-4">
|
||||
<button type="submit" class="btn btn-primary btn-block btn-flat">Register</button>
|
||||
</div>
|
||||
<!-- /.col -->
|
||||
</div>
|
||||
</form>
|
||||
<!--
|
||||
<div class="social-auth-links text-center">
|
||||
<p>- OR -</p>
|
||||
<a href="#" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> Sign up using
|
||||
Facebook</a>
|
||||
<a href="#" class="btn btn-block btn-social btn-google btn-flat"><i class="fa fa-google-plus"></i> Sign up using
|
||||
Google+</a>
|
||||
</div>
|
||||
-->
|
||||
|
||||
<a href="login.html" class="text-center">I already have a membership</a>
|
||||
</div>
|
||||
<!-- /.form-box -->
|
||||
</div>
|
||||
<!-- /.register-box -->
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in New Issue