Merge branch 'feature/sponsors' into dev
This commit is contained in:
commit
7c17b248bb
|
@ -13,6 +13,16 @@ if [ "$UPGRADE_DB" = "true" ]; then
|
||||||
pipenv run flask db upgrade
|
pipenv run flask db upgrade
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$RESET_DB" = "true" ]; then
|
||||||
|
echo 'Clearing database and loading example data...'
|
||||||
|
pipenv run flask load-example-data
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$LOAD_EXAMPLE_SPONSORS" = "true" ]; then
|
||||||
|
echo 'Loading example data...'
|
||||||
|
pipenv run flask load-example-sponsors
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$APPLICATION_ROOT" = "/" ]; then
|
if [ "$APPLICATION_ROOT" = "/" ]; then
|
||||||
pipenv run gunicorn --bind 0.0.0.0:$PORT0 wsgi:app
|
pipenv run gunicorn --bind 0.0.0.0:$PORT0 wsgi:app
|
||||||
else
|
else
|
||||||
|
|
|
@ -34,9 +34,14 @@ class ExampleDataLoader:
|
||||||
# row[3]: SP_TYPE
|
# row[3]: SP_TYPE
|
||||||
first_line = False
|
first_line = False
|
||||||
elif int(row[0] or -1) != -1:
|
elif int(row[0] or -1) != -1:
|
||||||
new_sponsor = Sponsor(SPONSOR_ID=int(row[0]), SP_NAME=row[1], SP_MAILING_ADDRESS=row[2], SP_TYPE=row[3])
|
sponsor_id = int(row[0])
|
||||||
new_sponsor.SP_TYPE_GROUP_NAME = Sponsor.get_type_group_name(new_sponsor.SP_TYPE)
|
is_duplicate = session.query(Sponsor).filter(Sponsor.SPONSOR_ID == sponsor_id).count() > 0
|
||||||
sponsors.append(new_sponsor)
|
|
||||||
|
# Make sure we're not creating duplicates
|
||||||
|
if not is_duplicate:
|
||||||
|
new_sponsor = Sponsor(SPONSOR_ID=sponsor_id, SP_NAME=row[1], SP_MAILING_ADDRESS=row[2], SP_TYPE=row[3])
|
||||||
|
new_sponsor.SP_TYPE_GROUP_NAME = Sponsor.get_type_group_name(new_sponsor.SP_TYPE)
|
||||||
|
sponsors.append(new_sponsor)
|
||||||
|
|
||||||
session.add_all(sponsors)
|
session.add_all(sponsors)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
|
@ -403,6 +403,7 @@ def _update_study(study, form):
|
||||||
|
|
||||||
study.STUDYID = max_id + 1
|
study.STUDYID = max_id + 1
|
||||||
else:
|
else:
|
||||||
|
# Delete existing required documents for this study.
|
||||||
db.session.query(RequiredDocument).filter(RequiredDocument.STUDYID == study.STUDYID).delete()
|
db.session.query(RequiredDocument).filter(RequiredDocument.STUDYID == study.STUDYID).delete()
|
||||||
|
|
||||||
study.TITLE = form.TITLE.data
|
study.TITLE = form.TITLE.data
|
||||||
|
|
|
@ -85,6 +85,12 @@ class Sanity_Check_Test(unittest.TestCase):
|
||||||
self.assertEqual(num_docs_before, num_docs_after)
|
self.assertEqual(num_docs_before, num_docs_after)
|
||||||
self.assertEqual(num_studies_before, num_studies_after)
|
self.assertEqual(num_studies_before, num_studies_after)
|
||||||
|
|
||||||
|
def test_add_sponsors(self):
|
||||||
|
"""Load sponsors twice in a row to make sure duplicates aren't created."""
|
||||||
|
self.load_sponsors()
|
||||||
|
self.load_sponsors()
|
||||||
|
|
||||||
|
|
||||||
def test_add_and_edit_study_sponsor(self):
|
def test_add_and_edit_study_sponsor(self):
|
||||||
"""Add and edit a study sponsor"""
|
"""Add and edit a study sponsor"""
|
||||||
num_sponsors = 5
|
num_sponsors = 5
|
||||||
|
|
Loading…
Reference in New Issue