schools dropdown
This commit is contained in:
parent
1857e15791
commit
35c0197a40
5 changed files with 2268 additions and 37 deletions
|
@ -30,46 +30,47 @@ def register():
|
||||||
school = request.form.get('school')
|
school = request.form.get('school')
|
||||||
phone = request.form.get('phone_number')
|
phone = request.form.get('phone_number')
|
||||||
gender = request.form.get('gender')
|
gender = request.form.get('gender')
|
||||||
|
print(school)
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
)
|
# )
|
||||||
db.session.add(user)
|
# db.session.add(user)
|
||||||
db.session.commit()
|
# db.session.commit()
|
||||||
flask_login.login_user(user)
|
# 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)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from wtforms import BooleanField, PasswordField, SelectField, StringField, SubmitField, widgets
|
from wtforms import BooleanField, PasswordField, SelectField, StringField, SubmitField, widgets
|
||||||
from wtforms.validators import DataRequired
|
from wtforms.validators import DataRequired
|
||||||
|
import os
|
||||||
|
|
||||||
class RegisterForm(FlaskForm):
|
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()])
|
email = StringField("Email", validators=[DataRequired()])
|
||||||
first_name = StringField("Preferred First Name",
|
first_name = StringField("Preferred First Name",
|
||||||
validators=[DataRequired()])
|
validators=[DataRequired()])
|
||||||
|
@ -10,12 +14,13 @@ class RegisterForm(FlaskForm):
|
||||||
password = PasswordField("Password", validators=[DataRequired()])
|
password = PasswordField("Password", validators=[DataRequired()])
|
||||||
password_confirm = PasswordField("Confirm Password",
|
password_confirm = PasswordField("Confirm Password",
|
||||||
validators=[DataRequired()])
|
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()])
|
phone_number = StringField("Phone number", validators=[DataRequired()])
|
||||||
gender = SelectField("Gender", choices=[("F", "Female"), ("M", "Male"),
|
gender = SelectField("Gender", choices=[("F", "Female"), ("M", "Male"),
|
||||||
("NB", "Non-binary/Other")],
|
("NB", "Non-binary/Other")],
|
||||||
widget=widgets.Select())
|
widget=widgets.Select())
|
||||||
agree_coc = BooleanField("I confirm that I have read and agree to the Code of Conduct", validators=[DataRequired()])
|
agree_coc = BooleanField("I confirm that I have read and agree to the Code of Conduct", validators=[DataRequired()])
|
||||||
|
|
||||||
submit = SubmitField("Register")
|
submit = SubmitField("Register")
|
||||||
|
|
||||||
class LoginForm(FlaskForm):
|
class LoginForm(FlaskForm):
|
||||||
|
|
2225
goathacks/registration/schools.txt
Normal file
2225
goathacks/registration/schools.txt
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1 +1 @@
|
||||||
Subproject commit 9c17c56d0aab937f041334bfe7f4146bf2069659
|
Subproject commit a107d4daf149bac2b8bd1182b399e57e8171c1f8
|
Loading…
Add table
Reference in a new issue