schools dropdown

This commit is contained in:
warren yun 2024-10-20 21:55:25 -04:00 committed by Cara Salter
parent 1857e15791
commit 35c0197a40
5 changed files with 2268 additions and 37 deletions

View file

@ -30,46 +30,47 @@ def register():
school = request.form.get('school')
phone = request.form.get('phone_number')
gender = request.form.get('gender')
print(school)
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
# )
# 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)

View file

@ -1,8 +1,12 @@
from flask_wtf import FlaskForm
from wtforms import BooleanField, PasswordField, SelectField, StringField, SubmitField, widgets
from wtforms.validators import DataRequired
import os
class RegisterForm(FlaskForm):
__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
schools_list = open(os.path.join(__location__, 'schools.txt')).read().split("\n")
email = StringField("Email", validators=[DataRequired()])
first_name = StringField("Preferred First Name",
validators=[DataRequired()])
@ -10,12 +14,13 @@ class RegisterForm(FlaskForm):
password = PasswordField("Password", validators=[DataRequired()])
password_confirm = PasswordField("Confirm Password",
validators=[DataRequired()])
school = StringField("School/University", validators=[DataRequired()])
school = SelectField("School", choices=[(school, school) for school in schools_list], widget=widgets.Select())
phone_number = StringField("Phone number", validators=[DataRequired()])
gender = SelectField("Gender", choices=[("F", "Female"), ("M", "Male"),
("NB", "Non-binary/Other")],
widget=widgets.Select())
agree_coc = BooleanField("I confirm that I have read and agree to the Code of Conduct", validators=[DataRequired()])
submit = SubmitField("Register")
class LoginForm(FlaskForm):

File diff suppressed because it is too large Load diff

@ -1 +1 @@
Subproject commit 9c17c56d0aab937f041334bfe7f4146bf2069659
Subproject commit a107d4daf149bac2b8bd1182b399e57e8171c1f8