Removed exceptions, found a better way to handle them.

Refactored the forms so that fields like email_address can be used in multiple forms.
Refactored form validation so that a query function is passed into the form to be run, this
way the form is not exposed to the dao layer and the query is more efficient.

This PR still requires some frontend attention. Will work with Chris to update the templates.
This commit is contained in:
Rebecca Law
2016-01-08 15:12:14 +00:00
parent ceb78f49b4
commit c858869a52
13 changed files with 96 additions and 121 deletions

View File

@@ -3,7 +3,6 @@ from datetime import datetime
from sqlalchemy.orm import load_only
from app import db, login_manager
from app.main.exceptions import NoDataFoundException
from app.models import User
from app.main.encryption import hashpw
@@ -60,16 +59,11 @@ def update_mobile_number(id, mobile_number):
db.session.commit()
def update_password(email, password):
user = get_user_by_email(email)
if user:
user.password = hashpw(password)
user.password_changed_at = datetime.now()
db.session.add(user)
db.session.commit()
return user
else:
raise NoDataFoundException('The user does not exist')
def update_password(user, password):
user.password = hashpw(password)
user.password_changed_at = datetime.now()
db.session.add(user)
db.session.commit()
def find_all_email_address():