Clean up the file api so we don't have a bunch of extra stuff in there. Just include the raw data from the document spraedsheet if it is available.
This commit is contained in:
parent
1f3febe2df
commit
61ad371680
|
@ -108,15 +108,9 @@ class File(object):
|
|||
instance.irb_doc_code = model.irb_doc_code
|
||||
instance.type = model.type
|
||||
if model.irb_doc_code and model.irb_doc_code in doc_dictionary:
|
||||
instance.category = "/".join(filter(None, [doc_dictionary[model.irb_doc_code]['category1'],
|
||||
doc_dictionary[model.irb_doc_code]['category2'],
|
||||
doc_dictionary[model.irb_doc_code]['category3']]))
|
||||
instance.description = doc_dictionary[model.irb_doc_code]['description']
|
||||
instance.download_name = "/".join([instance.category, model.name])
|
||||
instance.document = doc_dictionary[model.irb_doc_code]
|
||||
else:
|
||||
instance.category = ""
|
||||
instance.description = ""
|
||||
instance.document = {}
|
||||
if data_model:
|
||||
instance.last_modified = data_model.date_created
|
||||
instance.latest_version = data_model.version
|
||||
|
@ -147,10 +141,8 @@ class FileSchema(Schema):
|
|||
model = File
|
||||
fields = ["id", "name", "is_status", "is_reference", "content_type",
|
||||
"primary", "primary_process_id", "workflow_spec_id", "workflow_id",
|
||||
"irb_doc_code", "last_modified", "latest_version", "type", "categories",
|
||||
"description", "category", "download_name", "size", "data_store",
|
||||
"irb_doc_code", "last_modified", "latest_version", "type", "size", "data_store",
|
||||
"document"]
|
||||
|
||||
unknown = INCLUDE
|
||||
type = EnumField(FileType)
|
||||
|
||||
|
|
|
@ -95,9 +95,8 @@ class TestStudyApi(BaseTest):
|
|||
self.assert_success(api_response)
|
||||
study = StudySchema().loads(api_response.get_data(as_text=True))
|
||||
self.assertEqual(1, len(study.files))
|
||||
self.assertEqual("UVA Compliance/PRC Approval", study.files[0]["category"])
|
||||
self.assertEqual("Cancer Center's PRC Approval Form", study.files[0]["description"])
|
||||
self.assertEqual("UVA Compliance/PRC Approval/anything.png", study.files[0]["download_name"])
|
||||
self.assertEqual("UVA Compliance", study.files[0]["document"]["category1"])
|
||||
self.assertEqual("Cancer Center's PRC Approval Form", study.files[0]["document"]["description"])
|
||||
|
||||
# TODO: WRITE A TEST FOR STUDY FILES
|
||||
|
||||
|
|
Loading…
Reference in New Issue