def register(): form = RegisterForm() if request.method == 'POST': if form.validate_on_submit(): if User.query.filter(User.email == form.email.data).count() > 0: form.email.errors.append("Email address already in use.") return view('register', form) user = User( name=form.name.data, email=form.email.data, password=form.password.data, phone_number="+{0}{1}".format(form.country_code.data, form.phone_number.data), area_code=str(form.phone_number.data)[0:3]) db.session.add(user) db.session.commit() login_user(user, remember=True) return redirect_to('home') else: return view('register', form) return view('register', form)
def login(): form = LoginForm() if request.method == "POST": if form.validate_on_submit(): candidate_user = User.query.filter(User.email == form.email.data).first() if candidate_user is None or not bcrypt.check_password_hash(candidate_user.password, form.password.data): form.password.errors.append("Invalid credentials.") return view("login", form) login_user(candidate_user, remember=True) return redirect_to("home") return view("login", form)
def login(): form = LoginForm() if request.method == 'POST': if form.validate_on_submit(): candidate_user = User.query.filter(User.email == form.email.data).first() if candidate_user is None or not bcrypt.check_password_hash(candidate_user.password, form.password.data): form.password.errors.append("Invalid credentials.") return view('login', form) login_user(candidate_user, remember=True) return redirect_to('home') return view('login', form)
def new_property(): form = VacationPropertyForm() if request.method == 'POST': if form.validate_on_submit(): host = User.query.get(current_user.get_id()) property = VacationProperty(form.description.data, form.image_url.data, host) db.session.add(property) db.session.commit() return redirect_to('properties') return view('property_new', form)
def new_property(): form = VacationPropertyForm() if request.method == "POST": if form.validate_on_submit(): host = User.query.get(current_user.get_id()) property = VacationProperty(form.description.data, form.image_url.data, host) db.session.add(property) db.session.commit() return redirect_to("properties") return view("property_new", form)
def register(): form = RegisterForm() if request.method == "POST": if form.validate_on_submit(): if User.query.filter(User.email == form.email.data).count() > 0: form.email.errors.append("Email address already in use.") return view("register", form) user = User( name=form.name.data, email=form.email.data, password=form.password.data, phone_number="+{0}{1}".format(form.country_code.data, form.phone_number.data), ) db.session.add(user) db.session.commit() login_user(user, remember=True) return redirect_to("home") else: return view("register", form) return view("register", form)
def home(): return view('home')
def home(): return view("home")
def test_view_renders_the_same_template_as_render_template(self): # assert assert view('home') == render_template('home.html')