Scaffold event models

Will be used to check people into workshops and meals to track event
attendance over time, could be used to generate a dynamic schedule

Signed-Off-By: Cara Salter <cara@devcara.com>
This commit is contained in:
Cara Salter 2023-12-01 13:26:06 -05:00
parent 05b70dcaa7
commit cc4fe8cea4
No known key found for this signature in database
GPG key ID: A8A3A601440EADA5
2 changed files with 66 additions and 1 deletions

View file

@ -41,7 +41,6 @@ class User(db.Model, UserMixin):
return hackers return hackers
@login.user_loader @login.user_loader
def user_loader(user_id): def user_loader(user_id):
return User.query.filter_by(id=user_id).first() return User.query.filter_by(id=user_id).first()
@ -56,3 +55,45 @@ class PwResetRequest(db.Model):
id = Column(String, primary_key=True) id = Column(String, primary_key=True)
user_id = Column(Integer, ForeignKey('user.id'), nullable=False) user_id = Column(Integer, ForeignKey('user.id'), nullable=False)
expires = Column(DateTime, nullable=False) expires = Column(DateTime, nullable=False)
"""
Represents an event within the hackathon, that can be checked into
"""
class Event(db.Model):
id = Column(Integer, 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)
category = Column(String, nullable=True)
def create_json_output(lis):
events = []
for e in lis:
events.append({
'id': e.id,
'name': e.name,
'description': e.description,
'location': e.location,
'start': e.start_time,
'end': e.end_time,
'category': e.category
})
return events
def get_checkins(self):
checkins = EventCheckins.query.filter_by(event_id=self.id).all()
return checkins
class EventCheckins(db.Model):
__tablename__ = "event_checkins"
id = Column(Integer, primary_key=True)
event_id = Column(Integer, ForeignKey('event.id'), nullable=False)
user_id = Column(Integer, ForeignKey('user.id'), nullable=False)

View file

@ -0,0 +1,24 @@
"""create event table
Revision ID: d6917765911f
Revises: 261c004968a4
Create Date: 2023-12-01 13:22:41.055221
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd6917765911f'
down_revision = '261c004968a4'
branch_labels = None
depends_on = None
def upgrade():
pass
def downgrade():
pass