Removing the doc_types from the protocol builder, as these will eventually contradict what is coming from IRB and should not be used as an reference. Also fixing a failing test and assuring that only one reference file ever exists with a given name.
This commit is contained in:
parent
560b8a8782
commit
dbe6701bb2
|
@ -59,41 +59,6 @@ class ProtocolBuilderInvestigatorSchema(ma.Schema):
|
|||
|
||||
|
||||
class ProtocolBuilderRequiredDocument(object):
|
||||
DOC_TYPES = {
|
||||
1: "Investigators Brochure",
|
||||
6: "Cancer Center's PRC Approval Form",
|
||||
8: "SOM CTO IND/IDE Review Letter",
|
||||
9: "HIRE Approval",
|
||||
10: "Cancer Center's PRC Approval Waiver",
|
||||
12: "Certificate of Confidentiality Application",
|
||||
14: "Institutional Biosafety Committee Approval",
|
||||
18: "SOM CTO Approval Letter - UVA PI Multisite Trial",
|
||||
20: "IRB Approval or Letter of Approval from Administration: Study Conducted at non- UVA Facilities ",
|
||||
21: "New Medical Device Form",
|
||||
22: "SOM CTO Review regarding need for IDE",
|
||||
23: "SOM CTO Review regarding need for IND",
|
||||
24: "InfoSec Approval",
|
||||
25: "Scientific Pre-review Documentation",
|
||||
26: "IBC Number",
|
||||
32: "IDS - Investigational Drug Service Approval",
|
||||
36: "RDRC Approval ",
|
||||
40: "SBS/IRB Approval-FERPA",
|
||||
41: "HIRE Standard Radiation Language",
|
||||
42: "COI Management Plan ",
|
||||
43: "SOM CTO Approval Letter-Non UVA, Non Industry PI MultiSite Study",
|
||||
44: "GRIME Approval",
|
||||
45: "GMEC Approval",
|
||||
46: "IRB Reliance Agreement Request Form- IRB-HSR is IRB of Record",
|
||||
47: "Non UVA IRB Approval - Initial and Last Continuation",
|
||||
48: "MR Physicist Approval- Use of Gadolinium",
|
||||
49: "SOM CTO Approval- Non- UVA Academia PI of IDE",
|
||||
51: "IDS Waiver",
|
||||
52: "Package Inserts",
|
||||
53: "IRB Reliance Agreement Request Form- IRB-HSR Not IRB of Record",
|
||||
54: "ESCRO Approval",
|
||||
57: "Laser Safety Officer Approval",
|
||||
}
|
||||
|
||||
def __init__(self, AUXDOCID: str, AUXDOC: str):
|
||||
self.AUXDOCID = AUXDOCID
|
||||
self.AUXDOC = AUXDOC
|
||||
|
|
|
@ -58,10 +58,14 @@ class FileService(object):
|
|||
def add_reference_file(name, content_type, binary_data):
|
||||
"""Create a file with the given name, but not associated with a spec or workflow.
|
||||
Only one file with the given reference name can exist."""
|
||||
file_model = FileModel(
|
||||
name=name,
|
||||
is_reference=True
|
||||
)
|
||||
file_model = session.query(FileModel). \
|
||||
filter(FileModel.is_reference == True). \
|
||||
filter(FileModel.name == name).first()
|
||||
if not file_model:
|
||||
file_model = FileModel(
|
||||
name=name,
|
||||
is_reference=True
|
||||
)
|
||||
return FileService.update_file(file_model, binary_data, content_type)
|
||||
|
||||
@staticmethod
|
||||
|
@ -145,4 +149,3 @@ class FileService(object):
|
|||
if not file_model:
|
||||
raise ApiError("file_not_found", "There is no reference file with the name '%s'" % file_name)
|
||||
return FileService.get_file_data(file_model.id, file_model)
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import os
|
||||
from unittest.mock import patch
|
||||
|
||||
from crc import app
|
||||
from crc.models.file import CONTENT_TYPES
|
||||
from crc import app, db
|
||||
from crc.models.file import CONTENT_TYPES, FileDataModel, FileModel
|
||||
from crc.scripts.study_info import StudyInfo
|
||||
from crc.services.file_service import FileService
|
||||
from crc.services.protocol_builder import ProtocolBuilderService
|
||||
|
@ -28,6 +28,14 @@ class TestStudyInfoService(BaseTest):
|
|||
content_type=CONTENT_TYPES['xls'])
|
||||
|
||||
def test_validate_returns_error_if_reference_files_do_not_exist(self):
|
||||
file_model = db.session.query(FileModel). \
|
||||
filter(FileModel.is_reference == True). \
|
||||
filter(FileModel.name == StudyInfo.IRB_PRO_CATEGORIES_FILE).first()
|
||||
if file_model:
|
||||
db.session.query(FileDataModel).filter(FileDataModel.file_model_id == file_model.id).delete()
|
||||
db.session.query(FileModel).filter(FileModel.id == file_model.id).delete()
|
||||
db.session.commit()
|
||||
db.session.flush()
|
||||
errors = StudyInfo.validate()
|
||||
self.assertTrue(len(errors) > 0)
|
||||
self.assertEquals("file_not_found", errors[0].code)
|
||||
|
|
Loading…
Reference in New Issue