update user schema

This commit is contained in:
warren yun 2024-10-22 17:56:14 -04:00
parent 0268f70f9b
commit e9446b97c7
2 changed files with 42 additions and 34 deletions

View file

@ -20,6 +20,10 @@ class User(db.Model, UserMixin):
school = Column(String, nullable=True) school = Column(String, nullable=True)
phone = Column(String, nullable=True) phone = Column(String, nullable=True)
gender = 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): def __str__(self):
return f"{self.first_name} {self.last_name} ({self.email})" return f"{self.first_name} {self.last_name} ({self.email})"

View file

@ -35,44 +35,48 @@ def register():
dietary_restrictions = request.form.get('dietary_restrictions') dietary_restrictions = request.form.get('dietary_restrictions')
newsletter = request.form.get('newsletter') newsletter = request.form.get('newsletter')
# if password == password_c: if password == password_c:
# # Passwords match! # Passwords match!
# # Count of all non-waitlisted hackers # Count of all non-waitlisted hackers
# num_not_waitlisted = len(User.query.filter_by(waitlisted=False).all()) num_not_waitlisted = len(User.query.filter_by(waitlisted=False).all())
# waitlisted = False waitlisted = False
# print(num_not_waitlisted) print(num_not_waitlisted)
# print(current_app.config['MAX_BEFORE_WAITLIST']) print(current_app.config['MAX_BEFORE_WAITLIST'])
# if num_not_waitlisted >= current_app.config['MAX_BEFORE_WAITLIST']: if num_not_waitlisted >= current_app.config['MAX_BEFORE_WAITLIST']:
# waitlisted = True waitlisted = True
# user = User( user = User(
# email=email, email=email,
# password=generate_password_hash(password), password=generate_password_hash(password),
# first_name=first_name, first_name=first_name,
# last_name=last_name, last_name=last_name,
# last_login=datetime.now(), last_login=datetime.now(),
# waitlisted=waitlisted, waitlisted=waitlisted,
# school=school, school=school,
# phone=phone, phone=phone,
# gender=gender gender=gender,
# ) country=country,
# db.session.add(user) age=age,
# db.session.commit() dietary_restrictions=dietary_restrictions,
# flask_login.login_user(user) newsletter=newsletter
)
db.session.add(user)
db.session.commit()
flask_login.login_user(user)
# if waitlisted: if waitlisted:
# msg = Message("Goathacks - Waitlist Confirmation") msg = Message("Goathacks - Waitlist Confirmation")
# else: else:
# msg = Message("GoatHacks - Registration Confirmation") msg = Message("GoatHacks - Registration Confirmation")
# msg.add_recipient(user.email) msg.add_recipient(user.email)
# msg.sender = ("GoatHacks Team", "hack@wpi.edu") msg.sender = ("GoatHacks Team", "hack@wpi.edu")
# msg.body = render_template("emails/registration.txt", user=user) msg.body = render_template("emails/registration.txt", user=user)
# app_mail.send(msg) app_mail.send(msg)
# return redirect(url_for("dashboard.home")) return redirect(url_for("dashboard.home"))
# else: else:
# flash("Passwords do not match") flash("Passwords do not match")
return render_template("register.html", form=form) return render_template("register.html", form=form)