From d6302ea6739ed8b2d8fe77c5edf2525f552f88e8 Mon Sep 17 00:00:00 2001 From: Cara Salter <cara@devcara.com> Date: Sun, 3 Mar 2024 20:29:35 -0500 Subject: [PATCH] Init "join" and "dashboard" pages --- acmsite/__init__.py | 3 ++ acmsite/dashboard/__init__.py | 9 +++++ acmsite/models.py | 9 +++++ acmsite/templates/dashboard.html | 16 +++++++++ acmsite/templates/join.html | 3 ++ acmsite/templates/layout.html | 4 +-- .../6d239e987242_create_event_table.py | 36 +++++++++++++++++++ 7 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 acmsite/dashboard/__init__.py create mode 100644 acmsite/templates/dashboard.html create mode 100644 migrations/versions/6d239e987242_create_event_table.py diff --git a/acmsite/__init__.py b/acmsite/__init__.py index 1e03b66..378b8d3 100644 --- a/acmsite/__init__.py +++ b/acmsite/__init__.py @@ -45,5 +45,8 @@ def create_app(): from .auth import bp as auth_bp app.register_blueprint(auth_bp) + from .dashboard import bp as dash_bp + app.register_blueprint(dash_bp) + return app diff --git a/acmsite/dashboard/__init__.py b/acmsite/dashboard/__init__.py new file mode 100644 index 0000000..cda7b5e --- /dev/null +++ b/acmsite/dashboard/__init__.py @@ -0,0 +1,9 @@ + +from flask import Blueprint, render_template + + +bp = Blueprint('dashboard', __name__, url_prefix='/dashboard') + +@bp.route("/") +def home(): + return render_template('dashboard.html') diff --git a/acmsite/models.py b/acmsite/models.py index c260dec..d300966 100644 --- a/acmsite/models.py +++ b/acmsite/models.py @@ -29,3 +29,12 @@ class PwResetRequest(db.Model): id = Column(String, primary_key=True) user_id = Column(String, ForeignKey('acm_users.id'), nullable=False) expires = Column(DateTime, nullable=False) + +class Event(db.Model): + __tablename__ = "acm_events" + id = Column(String, primary_key=True) + name = Column(String, nullable=False) + description = Column(String, nullable=True) + location = Column(String, nullable=False) + start_time=Column(DateTime, nullable=False) + end_time=Column(DateTime, nullable=False) diff --git a/acmsite/templates/dashboard.html b/acmsite/templates/dashboard.html new file mode 100644 index 0000000..c88eaf5 --- /dev/null +++ b/acmsite/templates/dashboard.html @@ -0,0 +1,16 @@ +{% extends "layout.html" %} + +{% block app_content %} + +<h1>Welcome back, {{ current_user.first_name }}!</h1> + +<p>For a list of upcoming events, take a look at our <a href="{{ + url_for('main.events') + }}">events + listing</a>. + Otherwise, there's not + a whole lot here + unless you're an + officer!</p> + +{% endblock app_content %} diff --git a/acmsite/templates/join.html b/acmsite/templates/join.html index 5a7a3ed..0ea6a3d 100644 --- a/acmsite/templates/join.html +++ b/acmsite/templates/join.html @@ -3,6 +3,9 @@ {% block app_content %} <h1>Join ACM</h1> + <p>Want to join us? Show up to our GBMs and events every week!</p> +<p>Our upcoming events are:</p> + {% endblock %} diff --git a/acmsite/templates/layout.html b/acmsite/templates/layout.html index 918c112..c20a47a 100644 --- a/acmsite/templates/layout.html +++ b/acmsite/templates/layout.html @@ -34,9 +34,9 @@ </ul> <ul class="nav navbar-nav"> {% if current_user.is_authenticated %} - {{ render_nav_item('main.homepage', 'Dashboard') }} + {{ render_nav_item('dashboard.home', 'Dashboard') }} {% if current_user.is_admin %} - {{ render_nav_item('main.homepage', 'Admin Dash') }} + {{ render_nav_item('dashboard.home', 'Admin Dash') }} {% endif %} {{ render_nav_item('auth.logout', 'Logout') }} {% else %} diff --git a/migrations/versions/6d239e987242_create_event_table.py b/migrations/versions/6d239e987242_create_event_table.py new file mode 100644 index 0000000..392f3e1 --- /dev/null +++ b/migrations/versions/6d239e987242_create_event_table.py @@ -0,0 +1,36 @@ +"""Create event table + +Revision ID: 6d239e987242 +Revises: 7cdd046a2abf +Create Date: 2024-03-03 20:20:57.235877 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '6d239e987242' +down_revision = '7cdd046a2abf' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('acm_events', + sa.Column('id', sa.String(), nullable=False), + sa.Column('name', sa.String(), nullable=False), + sa.Column('description', sa.String(), nullable=True), + sa.Column('location', sa.String(), nullable=False), + sa.Column('start_time', sa.DateTime(), nullable=False), + sa.Column('end_time', sa.DateTime(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('acm_events') + # ### end Alembic commands ###