diff --git a/crc/api/study.py b/crc/api/study.py index 0433857c..4f5aa7ed 100644 --- a/crc/api/study.py +++ b/crc/api/study.py @@ -47,6 +47,8 @@ def update_study(study_id, body): def get_study(study_id): study_service = StudyService() study = study_service.get_study(study_id) +` if(study is None): + raise ApiError("Study not found", status_code=404) schema = StudySchema() return schema.dump(study) diff --git a/crc/services/file_service.py b/crc/services/file_service.py index 80e804de..5e331f3e 100644 --- a/crc/services/file_service.py +++ b/crc/services/file_service.py @@ -1,3 +1,4 @@ +import json import os from datetime import datetime from uuid import UUID @@ -67,7 +68,14 @@ class FileService(object): data_model = FileService.get_reference_file_data(FileService.IRB_PRO_CATEGORIES_FILE) xls = ExcelFile(data_model.data) df = xls.parse(xls.sheet_names[0]) - return df.set_index('Code').to_dict('index') + df['Id'] = df['Id'].fillna(0) + df = df.astype({'Id': 'Int64'}) + df = df.fillna('') + df = df.applymap(str) + df = df.set_index('Code') + # IF we need to convert the column names to something more sensible. + # df.columns = [snakeCase(x) for x in df.columns] + return json.loads(df.to_json(orient='index')) # # Pandas is lovely, but weird. Here we drop records without an Id, and convert it to an integer. # df = df.drop_duplicates(subset='Id').astype({'Id': 'Int64'}) # Now we index on the ID column and convert to a dictionary, where the key is the id, and the value diff --git a/crc/services/study_service.py b/crc/services/study_service.py index a939a67f..fd011c42 100644 --- a/crc/services/study_service.py +++ b/crc/services/study_service.py @@ -50,6 +50,7 @@ class StudyService(object): session.query(TaskEventModel).filter_by(study_id=study_id).delete() session.query(WorkflowModel).filter_by(study_id=study_id).delete() session.query(StudyModel).filter_by(id=study_id).delete() + session.commit() @staticmethod def get_categories(): diff --git a/crc/static/reference/irb_documents.xlsx b/crc/static/reference/irb_documents.xlsx index 9f3b0cdd..7743f0bc 100644 Binary files a/crc/static/reference/irb_documents.xlsx and b/crc/static/reference/irb_documents.xlsx differ diff --git a/tests/data/two_forms/mods/two_forms_struc_mod.bpmn b/tests/data/two_forms/mods/two_forms_struc_mod.bpmn index c3f73610..c726289a 100644 --- a/tests/data/two_forms/mods/two_forms_struc_mod.bpmn +++ b/tests/data/two_forms/mods/two_forms_struc_mod.bpmn @@ -27,7 +27,6 @@ SequenceFlow_00p5po6 SequenceFlow_17ggqu2 - We have a test that replaces tow_forms with this file, which adds a new step to the process.  A breaking change. diff --git a/tests/test_study_api.py b/tests/test_study_api.py index 5bf8337e..153395d7 100644 --- a/tests/test_study_api.py +++ b/tests/test_study_api.py @@ -195,6 +195,9 @@ class TestStudyApi(BaseTest): session.commit() rv = self.app.delete('/v1.0/study/%i' % study.id, headers=self.logged_in_headers()) self.assert_success(rv) + del_study = session.query(StudyModel).filter(StudyModel.id == study.id).first() + self.assertIsNone(del_study) + # """