From 036ca7b21e4da81c998603c3bbc0526085ef5fe4 Mon Sep 17 00:00:00 2001 From: Cara Salter Date: Tue, 6 Dec 2022 10:54:20 -0500 Subject: [PATCH] dash: Finish shirt size and accomodations selector --- goathacks/dashboard/__init__.py | 16 ++++++++++---- goathacks/dashboard/forms.py | 9 ++++++++ goathacks/models.py | 1 + goathacks/static/css/style.css | 10 +++++++++ goathacks/static/css/style.scss | 8 +++++++ goathacks/templates/dashboard.html | 27 ++++++++--------------- goathacks/templates/header.html | 1 + migrations/versions/3f427be4ce8a_.py | 33 ++++++++++++++++++++++++++++ 8 files changed, 83 insertions(+), 22 deletions(-) create mode 100644 goathacks/dashboard/forms.py create mode 100644 migrations/versions/3f427be4ce8a_.py diff --git a/goathacks/dashboard/__init__.py b/goathacks/dashboard/__init__.py index 1ef0ef6..ff4279f 100644 --- a/goathacks/dashboard/__init__.py +++ b/goathacks/dashboard/__init__.py @@ -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) diff --git a/goathacks/dashboard/forms.py b/goathacks/dashboard/forms.py new file mode 100644 index 0000000..753da09 --- /dev/null +++ b/goathacks/dashboard/forms.py @@ -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") diff --git a/goathacks/models.py b/goathacks/models.py index 3356bad..a3ef755 100644 --- a/goathacks/models.py +++ b/goathacks/models.py @@ -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 diff --git a/goathacks/static/css/style.css b/goathacks/static/css/style.css index 0cb192e..7383868 100644 --- a/goathacks/static/css/style.css +++ b/goathacks/static/css/style.css @@ -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; +} diff --git a/goathacks/static/css/style.scss b/goathacks/static/css/style.scss index 2dc6bb9..1b8da94 100644 --- a/goathacks/static/css/style.scss +++ b/goathacks/static/css/style.scss @@ -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; + } } diff --git a/goathacks/templates/dashboard.html b/goathacks/templates/dashboard.html index 4837411..546fbf7 100644 --- a/goathacks/templates/dashboard.html +++ b/goathacks/templates/dashboard.html @@ -70,27 +70,18 @@ class="btn btn-lg btn-primary btn-invert">Discord
-
+ + {{ form.csrf_token }}

Optional Info:

-

Shirt Size (Currently selected: {{shirt_size}})

- - - - - - - - - - - - - - +

Shirt Size (Currently selected: {{current_user.shirt_size}})

+ {% for subfield in form.shirt_size %} + {{subfield}}{{subfield.label}} + {% endfor %}

Special Needs/Accommodations:

- +


@@ -114,7 +105,7 @@ {% endif %}
- {% if admin %} + {% if current_user.is_admin %}

Admin Dashboard

diff --git a/goathacks/templates/header.html b/goathacks/templates/header.html index 821c007..bc6489a 100644 --- a/goathacks/templates/header.html +++ b/goathacks/templates/header.html @@ -4,6 +4,7 @@ + {% assets 'scss' %} {% endassets %} diff --git a/migrations/versions/3f427be4ce8a_.py b/migrations/versions/3f427be4ce8a_.py new file mode 100644 index 0000000..8c29441 --- /dev/null +++ b/migrations/versions/3f427be4ce8a_.py @@ -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 ###