update user schema
This commit is contained in:
parent
36bb39a8a0
commit
3c40553b45
2 changed files with 42 additions and 34 deletions
|
@ -20,6 +20,10 @@ class User(db.Model, UserMixin):
|
|||
school = Column(String, nullable=True)
|
||||
phone = Column(String, nullable=True)
|
||||
gender = Column(String, nullable=True)
|
||||
newsletter = Column(Boolean, nullable=False, default=False)
|
||||
country = Column(String, nullable=False)
|
||||
age = Column(Integer, nullable=False)
|
||||
dietary_restrictions = Column(String, nullable=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.first_name} {self.last_name} ({self.email})"
|
||||
|
|
|
@ -35,44 +35,48 @@ def register():
|
|||
dietary_restrictions = request.form.get('dietary_restrictions')
|
||||
newsletter = request.form.get('newsletter')
|
||||
|
||||
# if password == password_c:
|
||||
# # Passwords match!
|
||||
if password == password_c:
|
||||
# Passwords match!
|
||||
|
||||
# # Count of all non-waitlisted hackers
|
||||
# num_not_waitlisted = len(User.query.filter_by(waitlisted=False).all())
|
||||
# waitlisted = False
|
||||
# print(num_not_waitlisted)
|
||||
# print(current_app.config['MAX_BEFORE_WAITLIST'])
|
||||
# if num_not_waitlisted >= current_app.config['MAX_BEFORE_WAITLIST']:
|
||||
# waitlisted = True
|
||||
# user = User(
|
||||
# email=email,
|
||||
# password=generate_password_hash(password),
|
||||
# first_name=first_name,
|
||||
# last_name=last_name,
|
||||
# last_login=datetime.now(),
|
||||
# waitlisted=waitlisted,
|
||||
# school=school,
|
||||
# phone=phone,
|
||||
# gender=gender
|
||||
# )
|
||||
# db.session.add(user)
|
||||
# db.session.commit()
|
||||
# flask_login.login_user(user)
|
||||
# Count of all non-waitlisted hackers
|
||||
num_not_waitlisted = len(User.query.filter_by(waitlisted=False).all())
|
||||
waitlisted = False
|
||||
print(num_not_waitlisted)
|
||||
print(current_app.config['MAX_BEFORE_WAITLIST'])
|
||||
if num_not_waitlisted >= current_app.config['MAX_BEFORE_WAITLIST']:
|
||||
waitlisted = True
|
||||
user = User(
|
||||
email=email,
|
||||
password=generate_password_hash(password),
|
||||
first_name=first_name,
|
||||
last_name=last_name,
|
||||
last_login=datetime.now(),
|
||||
waitlisted=waitlisted,
|
||||
school=school,
|
||||
phone=phone,
|
||||
gender=gender,
|
||||
country=country,
|
||||
age=age,
|
||||
dietary_restrictions=dietary_restrictions,
|
||||
newsletter=newsletter
|
||||
)
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
flask_login.login_user(user)
|
||||
|
||||
# if waitlisted:
|
||||
# msg = Message("Goathacks - Waitlist Confirmation")
|
||||
# else:
|
||||
# msg = Message("GoatHacks - Registration Confirmation")
|
||||
if waitlisted:
|
||||
msg = Message("Goathacks - Waitlist Confirmation")
|
||||
else:
|
||||
msg = Message("GoatHacks - Registration Confirmation")
|
||||
|
||||
# msg.add_recipient(user.email)
|
||||
# msg.sender = ("GoatHacks Team", "hack@wpi.edu")
|
||||
# msg.body = render_template("emails/registration.txt", user=user)
|
||||
# app_mail.send(msg)
|
||||
msg.add_recipient(user.email)
|
||||
msg.sender = ("GoatHacks Team", "hack@wpi.edu")
|
||||
msg.body = render_template("emails/registration.txt", user=user)
|
||||
app_mail.send(msg)
|
||||
|
||||
# return redirect(url_for("dashboard.home"))
|
||||
# else:
|
||||
# flash("Passwords do not match")
|
||||
return redirect(url_for("dashboard.home"))
|
||||
else:
|
||||
flash("Passwords do not match")
|
||||
|
||||
return render_template("register.html", form=form)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue