Add Officer model and migration
Will enable dynamic creation of officer page and keeping track of past exec
This commit is contained in:
parent
fd8dd40138
commit
42e6c91d1b
2 changed files with 45 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
from flask import flash, redirect, url_for
|
from flask import flash, redirect, url_for
|
||||||
from flask_login import UserMixin
|
from flask_login import UserMixin
|
||||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String, null
|
from sqlalchemy import Boolean, Column, Date, DateTime, ForeignKey, Integer, String, null
|
||||||
import csv
|
import csv
|
||||||
from . import db
|
from . import db
|
||||||
from . import login
|
from . import login
|
||||||
|
@ -35,6 +35,14 @@ def unauth():
|
||||||
flash("Please log in first!")
|
flash("Please log in first!")
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
|
||||||
|
class Officer(db.Model):
|
||||||
|
__tablename__ = "acm_officers"
|
||||||
|
id = Column(String, primary_key=True)
|
||||||
|
user_id = Column(String, ForeignKey('acm_users.id'), nullable=False)
|
||||||
|
term_start = Column(Date, nullable=False)
|
||||||
|
term_end = Column(Date, nullable=True)
|
||||||
|
position = Column(String, nullable=False)
|
||||||
|
|
||||||
class PwResetRequest(db.Model):
|
class PwResetRequest(db.Model):
|
||||||
id = Column(String, primary_key=True)
|
id = Column(String, primary_key=True)
|
||||||
user_id = Column(String, ForeignKey('acm_users.id'), nullable=False)
|
user_id = Column(String, ForeignKey('acm_users.id'), nullable=False)
|
||||||
|
|
36
migrations/versions/4fa893cdd432_create_officers_table.py
Normal file
36
migrations/versions/4fa893cdd432_create_officers_table.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
"""Create officers table
|
||||||
|
|
||||||
|
Revision ID: 4fa893cdd432
|
||||||
|
Revises: 69cccb10f676
|
||||||
|
Create Date: 2024-03-22 13:54:39.037307
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '4fa893cdd432'
|
||||||
|
down_revision = '69cccb10f676'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('acm_officers',
|
||||||
|
sa.Column('id', sa.String(), nullable=False),
|
||||||
|
sa.Column('user_id', sa.String(), nullable=False),
|
||||||
|
sa.Column('term_start', sa.Date(), nullable=False),
|
||||||
|
sa.Column('term_end', sa.Date(), nullable=True),
|
||||||
|
sa.Column('position', sa.String(), nullable=False),
|
||||||
|
sa.ForeignKeyConstraint(['user_id'], ['acm_users.id'], ),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_table('acm_officers')
|
||||||
|
# ### end Alembic commands ###
|
Loading…
Add table
Reference in a new issue