From 862b8615143166a2c9f2f0a49a690c28d93ae05f Mon Sep 17 00:00:00 2001 From: Richard Qi Date: Tue, 23 Jul 2024 19:43:51 -0700 Subject: [PATCH 1/5] Fix observation #14 in FOIMOD-3300 --- .../Home/CreateResponsePDF/useSaveRedlineForSignOff.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js b/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js index 821ebf97f..07cb10f15 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 = {}; @@ -1410,7 +1408,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 +1506,7 @@ const stampPageNumberRedline = async ( stitchObject, PDFNet, redlineStitchInfo[divisionid]["stitchpages"], - redlineSinglePackage + isSingleRedlinePackage ); } //OIPC - Special Block : End @@ -1546,7 +1544,7 @@ const stampPageNumberRedline = async ( redlineIncompatabileMappings[divisionid], redlineStitchInfo[divisionid]["s3path"], divisionCountForToast, - redlineSinglePackage + isSingleRedlinePackage ); }, (_err) => { From 71b8dad76b65ac7378caf2ef80a10699eb0761ba Mon Sep 17 00:00:00 2001 From: Richard Qi Date: Wed, 24 Jul 2024 14:00:28 -0700 Subject: [PATCH 2/5] Fix observation 14 in FOIMOD-3300 --- api/reviewer_api/resources/foiflowmasterdata.py | 13 ++++++++----- api/reviewer_api/utils/util.py | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/api/reviewer_api/resources/foiflowmasterdata.py b/api/reviewer_api/resources/foiflowmasterdata.py index c42af161b..a8d61ccdf 100644 --- a/api/reviewer_api/resources/foiflowmasterdata.py +++ b/api/reviewer_api/resources/foiflowmasterdata.py @@ -172,7 +172,7 @@ class FOIFlowS3PresignedRedline(Resource): def post(ministryrequestid, redactionlayer="redline", layertype="redline"): try: data = request.get_json() - requesttype = data["divdocumentList"] + requesttype = data["requestType"] documentmapper = redactionservice().getdocumentmapper( data["divdocumentList"][0]["documentlist"][0]["filepath"].split("/")[3] ) @@ -199,11 +199,14 @@ 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) for div in data["divdocumentList"]: if len(div["documentlist"]) > 0: 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,7 +264,7 @@ 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:] @@ -282,7 +285,7 @@ def post(ministryrequestid, redactionlayer="redline", layertype="redline"): 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 +304,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 From 00c496cc49b164ab6e6bc99ebc3108c3c93bffeb Mon Sep 17 00:00:00 2001 From: Aparna Date: Thu, 25 Jul 2024 13:36:30 -0700 Subject: [PATCH 3/5] Adding debug codes --- api/reviewer_api/resources/foiflowmasterdata.py | 7 ++++++- .../FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/api/reviewer_api/resources/foiflowmasterdata.py b/api/reviewer_api/resources/foiflowmasterdata.py index a8d61ccdf..4dd14b0d9 100644 --- a/api/reviewer_api/resources/foiflowmasterdata.py +++ b/api/reviewer_api/resources/foiflowmasterdata.py @@ -202,9 +202,11 @@ def post(ministryrequestid, redactionlayer="redline", layertype="redline"): #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 == False: division_name = div["divisionname"] @@ -268,10 +270,13 @@ def post(ministryrequestid, redactionlayer="redline", layertype="redline"): 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={ diff --git a/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js b/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js index 07cb10f15..4b6b636d4 100644 --- a/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js +++ b/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js @@ -784,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; @@ -984,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]; @@ -1007,7 +1008,7 @@ const useSaveRedlineForSignoff = (initDocInstance, initDocViewer) => { if (divisionCountForToast === zipServiceMessage.attributes.length) { triggerDownloadRedlines(zipServiceMessage, (error) => { console.log(error); - window.location.reload(); + //window.location.reload(); }); } return zipServiceMessage; From 56002982f106759b9aff7024e203be2d6d3c1fdf Mon Sep 17 00:00:00 2001 From: Aparna Date: Thu, 25 Jul 2024 14:08:56 -0700 Subject: [PATCH 4/5] debug code --- api/reviewer_api/resources/foiflowmasterdata.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/reviewer_api/resources/foiflowmasterdata.py b/api/reviewer_api/resources/foiflowmasterdata.py index 4dd14b0d9..b617d6746 100644 --- a/api/reviewer_api/resources/foiflowmasterdata.py +++ b/api/reviewer_api/resources/foiflowmasterdata.py @@ -172,6 +172,7 @@ class FOIFlowS3PresignedRedline(Resource): def post(ministryrequestid, redactionlayer="redline", layertype="redline"): try: data = request.get_json() + print("data!:",data) requesttype = data["requestType"] documentmapper = redactionservice().getdocumentmapper( data["divdocumentList"][0]["documentlist"][0]["filepath"].split("/")[3] @@ -287,6 +288,7 @@ def post(ministryrequestid, redactionlayer="redline", layertype="redline"): ExpiresIn=3600, HttpMethod="PUT", ) + print("s3path_save:",s3path_save) singlepkgpath = s3path_save data["s3path_save"] = s3path_save From 1d1d3167b9e2b05ab500e8813f70cfccafe0c0e5 Mon Sep 17 00:00:00 2001 From: Aparna Date: Thu, 25 Jul 2024 14:13:25 -0700 Subject: [PATCH 5/5] Reload uncommented --- .../FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js b/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js index 4b6b636d4..8b81c5c90 100644 --- a/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js +++ b/web/src/components/FOI/Home/CreateResponsePDF/useSaveRedlineForSignOff.js @@ -1008,7 +1008,7 @@ const useSaveRedlineForSignoff = (initDocInstance, initDocViewer) => { if (divisionCountForToast === zipServiceMessage.attributes.length) { triggerDownloadRedlines(zipServiceMessage, (error) => { console.log(error); - //window.location.reload(); + window.location.reload(); }); } return zipServiceMessage;