Merge branch 'dev' into rrt/dev

This commit is contained in:
Aaron Louie 2020-05-23 15:13:03 -04:00
commit 4584dda992
7 changed files with 49 additions and 12 deletions

View File

@ -17,7 +17,6 @@ RUN pip install pipenv && \
COPY . /app/
ENV FLASK_APP=/app/crc/__init__.py
CMD ["pipenv", "run", "flask", "db", "upgrade"]
CMD ["pipenv", "run", "python", "/app/run.py"]
# expose ports

View File

@ -32,7 +32,7 @@ def verify_token(token):
def get_current_user():
return UserModelSchema().dump(g.user)
@app.route('/login')
@app.route('/v1.0/login')
def sso_login():
# This what I see coming back:
# X-Remote-Cn: Daniel Harold Funk (dhf8r)

View File

@ -18,7 +18,7 @@ class ApprovalModel(db.Model):
__tablename__ = 'approval'
id = db.Column(db.Integer, primary_key=True)
study_id = db.Column(db.Integer, db.ForeignKey(StudyModel.id), nullable=False)
study = db.relationship(StudyModel, backref='approval')
study = db.relationship(StudyModel, backref='approval', cascade='all,delete')
workflow_id = db.Column(db.Integer, db.ForeignKey(WorkflowModel.id), nullable=False)
workflow_version = db.Column(db.String)
approver_uid = db.Column(db.String) # Not linked to user model, as they may not have logged in yet.

View File

@ -3,17 +3,15 @@
# run migrations
export FLASK_APP=./crc/__init__.py
for entry in ./instance/* ; do
echo "$entry"
cat $entry
done
if [ "$DOWNGRADE_DB" = "true" ]; then
echo 'Downgrading...'
echo 'Downgrading database...'
pipenv run flask db downgrade
fi
pipenv run flask db upgrade
if [ "$UPGRADE_DB" = "true" ]; then
echo 'Upgrading database...'
pipenv run flask db upgrade
fi
if [ "$RESET_DB" = "true" ]; then
echo 'Resetting database...'

View File

@ -14,6 +14,7 @@ class ExampleDataLoader:
session.flush() # Clear out any transactions before deleting it all to avoid spurious errors.
for table in reversed(db.metadata.sorted_tables):
session.execute(table.delete())
session.commit()
session.flush()
def load_all(self):

View File

@ -0,0 +1,39 @@
"""empty message
Revision ID: 55c6cd407d89
Revises: cc4bccc5e5a8
Create Date: 2020-05-22 22:02:46.650170
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '55c6cd407d89'
down_revision = 'cc4bccc5e5a8'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('approval',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('study_id', sa.Integer(), nullable=False),
sa.Column('workflow_id', sa.Integer(), nullable=False),
sa.Column('workflow_version', sa.String(), nullable=True),
sa.Column('approver_uid', sa.String(), nullable=True),
sa.Column('status', sa.String(), nullable=True),
sa.Column('message', sa.String(), nullable=True),
sa.ForeignKeyConstraint(['study_id'], ['study.id'], ),
sa.ForeignKeyConstraint(['workflow_id'], ['workflow.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('approval')
# ### end Alembic commands ###

View File

@ -44,7 +44,7 @@ class TestAuthentication(BaseTest):
self.assertIsNone(user)
redirect_url = 'http://worlds.best.website/admin'
headers = dict(Uid=new_uid)
rv = self.app.get('login', follow_redirects=False, headers=headers)
rv = self.app.get('v1.0/login', follow_redirects=False, headers=headers)
self.assert_success(rv)
user = db.session.query(UserModel).filter(UserModel.uid == new_uid).first()
self.assertIsNotNone(user)