def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): employee = Employee(Employeenumber=form.employeeNumber.data, EmployeeName=form.employeeName.data, EmployeeAddress=form.employeeAddress.data, EmployeeCity=form.employeeCity.data, EmployeeState=form.employeeState.data, EmployeeZip=form.employeeZip.data, EmployeeBirthDate=form.employeeBirthDate.data, DepartmentID=form.employeeDepartmentID.data) db.session.add(employee) db.session.commit() hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') print(hashed_password) loginid = Login(LoginID=form.loginid.data, Employeenumber=form.employeeNumber.data, Password=hashed_password) db.session.add(loginid) db.session.commit() flash('Your account has been created! You are now able to log in', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() flash('Your account has been created! You are now able to log in', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('choices')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8') Employee = employee(firstName=form.firstName.data,lastName=form.lastName.data,username=form.username.data,password=hashed_password,phoneNumber = form.phone.data,email = form.email.data,roleName = form.position.data , verified= False) db.session.add(Employee) db.session.commit() flash('Your account has been created! You are now able to log in', 'success') return redirect(url_for('login')) return render_template('register.html', form=form)
def registration(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(fname=form.fname.data, lname=form.lname.data, email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() flash(f'Welcome, {form.fname.data}!', 'success') return redirect(url_for('login')) return render_template("registration.html", title="Registration", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User1(UName=form.uname.data, FName=form.firstname.data, LName=form.lastname.data, DOB=form.dateofbirth.data, Email=form.email.data, Password=hashed_password, User1_type_id=form.user1typeid.data, Address=form.address.data) # user = User1(username=form.username.data, Email=form.email.data, Password=hashed_password) db.session.add(user) db.session.commit() flash('Your account has been created! You are now able to log in', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): vid = request.args.get('vid') pickup = request.args.get('pickup') dropoff = request.args.get('dropoff') dateFrom = request.args.get('dateFrom') dateTo = request.args.get('dateTo') dateT = datetime.strptime("{}".format(dateTo), "%Y-%m-%d %H:%M:%S") dateF = datetime.strptime("{}".format(dateFrom), "%Y-%m-%d %H:%M:%S") diff = abs((dateF - dateT).days) car = Vehicle.query.get_or_404(vid) amount = diff * car.rate tax = Decimal(amount) * Decimal(0.1) total = amount + tax form = RegistrationForm() if current_user.is_authenticated: customer = Customer.query.filter_by(email=current_user.email).first() reservation = Reservation(customerID=current_user.customerID, vehicleID=vid, dateFrom=dateFrom, dateTo=dateTo, pickupLocation=pickup, dropoffLocation=dropoff) flash('Your car has been reserved!', 'success') db.session.add(reservation) db.session.commit() return redirect(url_for('home')) # """ # if current_user.is_authenticated: # return redirect(url_for('home')) # datetime.datetime.strptime("{}, {}".format(date, time), "%m-%d-%Y, %H:%M") # """ elif form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') customer = Customer(username=form.username.data, email=form.email.data, password=hashed_password, fullName=form.fullname.data, phoneNumber=form.phonenumber.data) db.session.add(customer) db.session.commit() customer = Customer.query.filter_by(email=form.email.data).first() reservation = Reservation(customerID=customer.customerID, vehicleID=vid, dateFrom=dateFrom, dateTo=dateTo, pickupLocation=pickup, dropoffLocation=dropoff) db.session.add(reservation) db.session.commit() flash('Your car has been reserved and account has been created!', 'success') return redirect(url_for('home')) return render_template('register.html', title='Register', form=form, car=car, dateTo=dateTo, dateFrom=dateFrom, diff=diff, amount=amount, tax=tax, total=total)