diff --git a/api/reviewer_api/resources/foiflowmasterdata.py b/api/reviewer_api/resources/foiflowmasterdata.py index c42af161b..b617d6746 100644 --- a/api/reviewer_api/resources/foiflowmasterdata.py +++ b/api/reviewer_api/resources/foiflowmasterdata.py @@ -172,7 +172,8 @@ class FOIFlowS3PresignedRedline(Resource): def post(ministryrequestid, redactionlayer="redline", layertype="redline"): try: data = request.get_json() - requesttype = data["divdocumentList"] + print("data!:",data) + requesttype = data["requestType"] documentmapper = redactionservice().getdocumentmapper( data["divdocumentList"][0]["documentlist"][0]["filepath"].split("/")[3] ) @@ -199,11 +200,16 @@ def post(ministryrequestid, redactionlayer="redline", layertype="redline"): packagetype = "redline" if redactionlayer == "oipc": packagetype = "oipcreview" if layertype == "oipcreview" else "oipcredline" - + + #check if is single redline package + is_single_redline = is_single_redline_package(_bcgovcode, packagetype, requesttype) + print("is_single_redline:",is_single_redline) + #print("divdocumentList:",data["divdocumentList"]) for div in data["divdocumentList"]: if len(div["documentlist"]) > 0: + print("filepathlist:" , div["documentlist"][0]["filepath"]) filepathlist = div["documentlist"][0]["filepath"].split("/")[4:] - if is_single_redline_package(_bcgovcode, packagetype, requesttype) == False: + if is_single_redline == False: division_name = div["divisionname"] # generate save url for stitched file filepath_put = "{0}/{2}/{1}/{0} - {2} - {1}.pdf".format( @@ -261,14 +267,17 @@ def post(ministryrequestid, redactionlayer="redline", layertype="redline"): ) elif len(div["incompatableList"]) > 0: filepathlist = div["incompatableList"][0]["filepath"].split("/")[4:] - if is_single_redline_package(_bcgovcode, packagetype, requesttype) and singlepkgpath is None : + if is_single_redline and singlepkgpath is None : if len(div["documentlist"]) > 0 or len(div["incompatableList"]) > 0: div = data["divdocumentList"][0] filepathlist = div["documentlist"][0]["filepath"].split("/")[4:] + print("filepathlist:",filepathlist) filename = filepathlist[0] + print("filename1:",filename) filepath_put = "{0}/{2}/{1}-Redline.pdf".format( filepathlist[0],filename, packagetype ) + print("filepath_put:",filepath_put) s3path_save = s3client.generate_presigned_url( ClientMethod="get_object", Params={ @@ -279,10 +288,11 @@ def post(ministryrequestid, redactionlayer="redline", layertype="redline"): ExpiresIn=3600, HttpMethod="PUT", ) + print("s3path_save:",s3path_save) singlepkgpath = s3path_save data["s3path_save"] = s3path_save - if is_single_redline_package(_bcgovcode, packagetype, requesttype): + if is_single_redline: for div in data["divdocumentList"]: if len(div["documentlist"]) > 0: documentlist_copy = div["documentlist"][:] @@ -301,7 +311,7 @@ def post(ministryrequestid, redactionlayer="redline", layertype="redline"): data["requestnumber"] = filepathlist[0] data["bcgovcode"] = _bcgovcode - data["issingleredlinepackage"] = "Y" if is_single_redline_package(_bcgovcode, packagetype, requesttype) else "N" + data["issingleredlinepackage"] = "Y" if is_single_redline else "N" return json.dumps(data), 200 except BusinessException as exception: return {"status": exception.status_code, "message": exception.message}, 500 diff --git a/api/reviewer_api/utils/util.py b/api/reviewer_api/utils/util.py index 68414ac3d..0a5f52954 100644 --- a/api/reviewer_api/utils/util.py +++ b/api/reviewer_api/utils/util.py @@ -145,6 +145,6 @@ def is_single_redline_package(bcgovcode, packagetype, requesttype): return True if REDLINE_SINGLE_PKG_MINISTRIES_PERSONAL not in (None, ""): _pkg_ministries_personal = REDLINE_SINGLE_PKG_MINISTRIES_PERSONAL.replace(" ", "").split(',') - if bcgovcode.upper() in _pkg_ministries_personal: + if bcgovcode.upper() in _pkg_ministries_personal and requesttype.upper() == "PERSONAL": return True return False \ No newline at end of file diff --git a/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js b/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js index 821ebf97f..8b81c5c90 100644 --- a/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js +++ b/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js @@ -67,7 +67,6 @@ const useSaveRedlineForSignoff = (initDocInstance, initDocViewer) => { const [redlineCategory, setRedlineCategory] = useState(false); const [filteredComments, setFilteredComments] = useState({}); const [alreadyStitchedList, setAlreadyStitchedList] = useState([]); - const [redlineSinglePackage, setRedlineSinglePackage] = useState(null); const requestInfo = useAppSelector((state) => state.documents?.requestinfo); const requestType = requestInfo?.requesttype ? requestInfo.requesttype : "public"; @@ -769,7 +768,6 @@ const useSaveRedlineForSignoff = (initDocInstance, initDocViewer) => { render: `Start saving redline...`, isLoading: true, }); - //setRedlineSinglePackage(res.issingleredlinepackage); setIsSingleRedlinePackage(res.issingleredlinepackage); let stitchDoc = {}; @@ -786,7 +784,7 @@ const useSaveRedlineForSignoff = (initDocInstance, initDocViewer) => { let documentsObjArr = []; let divisionstitchpages = []; let divCount = 0; - + console.log("RES:",res) for (let div of res.divdocumentList) { divCount++; let docCount = 0; @@ -986,6 +984,7 @@ const useSaveRedlineForSignoff = (initDocInstance, initDocViewer) => { includenrpages: includeNRPages, }; if (stitchedDocPath) { + console.log("stitchedDocPath:",stitchedDocPath) const stitchedDocPathArray = stitchedDocPath?.split("/"); let fileName = stitchedDocPathArray[stitchedDocPathArray.length - 1].split("?")[0]; @@ -1410,7 +1409,7 @@ const stampPageNumberRedline = async ( currentDivisionCount++; toast.update(toastId.current, { render: - redlineSinglePackage == "N" + isSingleRedlinePackage == "N" ? `Saving redline PDF for ${divisionCountForToast} divisions to Object Storage...` : `Saving redline PDF to Object Storage...`, isLoading: true, @@ -1508,7 +1507,7 @@ const stampPageNumberRedline = async ( stitchObject, PDFNet, redlineStitchInfo[divisionid]["stitchpages"], - redlineSinglePackage + isSingleRedlinePackage ); } //OIPC - Special Block : End @@ -1546,7 +1545,7 @@ const stampPageNumberRedline = async ( redlineIncompatabileMappings[divisionid], redlineStitchInfo[divisionid]["s3path"], divisionCountForToast, - redlineSinglePackage + isSingleRedlinePackage ); }, (_err) => {