dash: Finish shirt size and accomodations selector
This commit is contained in:
parent
26468e82ea
commit
036ca7b21e
8 changed files with 83 additions and 22 deletions
|
@ -1,10 +1,18 @@
|
|||
from flask import Blueprint, render_template
|
||||
from flask_login import login_required
|
||||
from flask import Blueprint, flash, render_template, request
|
||||
from flask_login import current_user, login_required
|
||||
|
||||
bp = Blueprint("dashboard", __name__, url_prefix="/dashboard")
|
||||
|
||||
from goathacks.dashboard import forms
|
||||
from goathacks import db
|
||||
|
||||
@bp.route("/")
|
||||
@bp.route("/", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def home():
|
||||
return render_template("dashboard.html")
|
||||
form = forms.ShirtAndAccomForm(request.form)
|
||||
if request.method == "POST" and form.validate():
|
||||
current_user.shirt_size = request.form.get('shirt_size')
|
||||
current_user.accomodations = request.form.get('accomodations')
|
||||
db.session.commit()
|
||||
flash("Updated successfully")
|
||||
return render_template("dashboard.html", form=form)
|
||||
|
|
9
goathacks/dashboard/forms.py
Normal file
9
goathacks/dashboard/forms.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from flask_wtf import FlaskForm
|
||||
from wtforms import RadioField, TextAreaField
|
||||
from wtforms.validators import DataRequired
|
||||
|
||||
class ShirtAndAccomForm(FlaskForm):
|
||||
shirt_size = RadioField("Shirt size", choices=["XS", "S", "M", "L", "XL",
|
||||
"None"],
|
||||
validators=[DataRequired()])
|
||||
accomodations = TextAreaField("Special needs and/or Accomodations")
|
|
@ -16,6 +16,7 @@ class User(db.Model, UserMixin):
|
|||
waitlisted = Column(Boolean, nullable=False, default=False)
|
||||
shirt_size = Column(String, nullable=True)
|
||||
accomodations = Column(String, nullable=True)
|
||||
checked_in = Column(Boolean, nullable=False, default=False)
|
||||
|
||||
|
||||
@login.user_loader
|
||||
|
|
|
@ -145,3 +145,13 @@ form input[type="submit"] {
|
|||
border-radius: 10px;
|
||||
border-color: #26a69a;
|
||||
}
|
||||
|
||||
form input[type="radio"] {
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
form label {
|
||||
font-size: 1.1rem;
|
||||
padding-right: 10px;
|
||||
padding-left: 25px !important;
|
||||
}
|
||||
|
|
|
@ -145,4 +145,12 @@ form {
|
|||
border-radius: 10px;
|
||||
border-color: $color-accent;
|
||||
}
|
||||
input[type="radio"] {
|
||||
padding-right: 5px;
|
||||
}
|
||||
label {
|
||||
font-size: 1.1rem;
|
||||
padding-right: 10px;
|
||||
padding-left: 25px !important;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,27 +70,18 @@
|
|||
class="btn btn-lg btn-primary btn-invert">Discord</a>
|
||||
</div>
|
||||
<div class="row center justify-content-center" style="background-color: #974355; padding: 20; margin-left: 20; margin-right: 20; border-radius: 5px;">
|
||||
<form method="get" action="/shirtpost">
|
||||
<form method="post">
|
||||
{{ form.csrf_token }}
|
||||
<br>
|
||||
<p><b>Optional Info:</b></p>
|
||||
<div>
|
||||
<p>Shirt Size (Currently selected: {{shirt_size}})</p>
|
||||
<input type="radio" id="shirtxs" name="size" value="xs">
|
||||
<label for="shirtxs">XS</label>
|
||||
<input type="radio" id="shirts" name="size" value="s">
|
||||
<label for="shirts">S</label>
|
||||
<input type="radio" id="shirtm" name="size" value="m">
|
||||
<label for="shirtm">M</label>
|
||||
<input type="radio" id="shirtl" name="size" value="l">
|
||||
<label for="shirtl">L</label>
|
||||
<input type="radio" id="shirtxl" name="size" value="xl">
|
||||
<label for="shirtxl">XL</label>
|
||||
<input type="radio" id="shirtxxl" name="size" value="xxl">
|
||||
<label for="shirtxxl">XXL</label>
|
||||
<input type="radio" id="no" name="size" value="no">
|
||||
<label for="no">Don't want one</label>
|
||||
<p>Shirt Size (Currently selected: {{current_user.shirt_size}})</p>
|
||||
{% for subfield in form.shirt_size %}
|
||||
{{subfield}}{{subfield.label}}
|
||||
{% endfor %}
|
||||
<p>Special Needs/Accommodations:</p>
|
||||
<input type="text" name="special_needs" id="special_needs" value="{{ special_needs }}">
|
||||
<input type="text" name="accomodations"
|
||||
id="special_needs" value="{{ current_user.accomodations }}">
|
||||
</div>
|
||||
<br><br>
|
||||
<input name="save" class="btn btn-lg btn-primary btn-invert" type="submit" value="Save"/>
|
||||
|
@ -114,7 +105,7 @@
|
|||
{% endif %}
|
||||
<br>
|
||||
</div>
|
||||
{% if admin %}
|
||||
{% if current_user.is_admin %}
|
||||
<br>
|
||||
<div class="row justify-content-center">
|
||||
<a href="/admin"><p class="btn">Admin Dashboard</p></a>
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
<head>
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
||||
<link href="../static/css/materialize.min.css" rel="stylesheet">
|
||||
{% assets 'scss' %}
|
||||
<link rel="stylesheet" type="text/css" href="{{ ASSET_URL }}">
|
||||
{% endassets %}
|
||||
|
|
33
migrations/versions/3f427be4ce8a_.py
Normal file
33
migrations/versions/3f427be4ce8a_.py
Normal file
|
@ -0,0 +1,33 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 3f427be4ce8a
|
||||
Revises: 55d77cdbbb49
|
||||
Create Date: 2022-12-06 10:18:07.322064
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '3f427be4ce8a'
|
||||
down_revision = '55d77cdbbb49'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('checked_in', sa.Boolean(),
|
||||
nullable=False, default=False))
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('user', schema=None) as batch_op:
|
||||
batch_op.drop_column('checked_in')
|
||||
|
||||
# ### end Alembic commands ###
|
Loading…
Add table
Reference in a new issue