Merge branch 'master' into feature/made_base_form_class

This commit is contained in:
Kyle J. Roux 2017-05-16 13:50:26 -07:00 committed by GitHub
commit 68d16991cd
3 changed files with 10 additions and 16 deletions

10
app.py
View File

@ -4,7 +4,8 @@ from forms import ContactForm
# Flask
app = Flask(__name__)
app.secret_key = 'my secret'
app.config['SECRET_KEY'] = 'my secret'
app.config['DEBUG'] = True
# Database
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///book.sqlite'
@ -28,10 +29,10 @@ def new_contact():
'''
form = ContactForm()
if form.validate_on_submit():
my_contact = Contact()
form.populate_obj(my_contact)
db.session.add(my_contact)
try:
my_contact = Contact()
form.populate_obj(my_contact)
db.session.add(my_contact)
db.session.commit()
# User info
flash('Contact created correctly', 'success')
@ -107,5 +108,4 @@ def contacts_delete():
if __name__ == "__main__":
app.debug = True
app.run()

View File

@ -18,11 +18,5 @@ class Contact(db.Model):
email = db.Column(db.String(200), nullable=True, unique=True)
phone = db.Column(db.String(20), nullable=True, unique=False)
def __init__(self, name, surname, email, phone):
self.name = name
self.surname = surname
self.email = email
self.phone = phone
def __repr__(self):
return '<Contacts %r>' % self.name

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="es">
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
@ -18,7 +18,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Contactos</a>
<a class="navbar-brand" href="#">Contact Manager</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<form action="{{ url_for('search') }}" method="get" class="navbar-form navbar-left">