From b85017889da4c273614657cc0f0dd8c97592ce91 Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Tue, 20 Aug 2024 15:16:27 -0700 Subject: [PATCH 01/18] bug fix. no page flag being applied to page with no flags --- web/src/components/FOI/Home/utils.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/web/src/components/FOI/Home/utils.js b/web/src/components/FOI/Home/utils.js index fe926edf5..ef736a94f 100644 --- a/web/src/components/FOI/Home/utils.js +++ b/web/src/components/FOI/Home/utils.js @@ -783,6 +783,9 @@ export const skipNRDocument = (documentPageFlags, pagecount, pageFlagTypes) => { export const findNROrDuplicatePageFlag = (pageFlags, docObj, pageFlagTypes) => { const docPageFlags = pageFlags.find(pageFlagObj => pageFlagObj.documentid === docObj.docid); + if (!docPageFlags) { + return false; + } for (let pageFlag of docPageFlags.pageflag) { if ((pageFlag.page === docObj.page && pageFlag.flagid === pageFlagTypes["Duplicate"]) || (pageFlag.page === docObj.page && pageFlag.flagid === pageFlagTypes["Not Responsive"])) { return pageFlag; From 38502d83df454a813369a5e3e6afd8079f63f28f Mon Sep 17 00:00:00 2001 From: Abin Antony Date: Tue, 20 Aug 2024 17:51:04 -0700 Subject: [PATCH 02/18] #FOIMOD-3416 Logs enabling --- .../services/dts/redactionsummary.py | 57 +++++++++++-------- .../services/redactionsummaryservice.py | 14 +++-- 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/computingservices/DocumentServices/services/dts/redactionsummary.py b/computingservices/DocumentServices/services/dts/redactionsummary.py index a70208a3f..0a05f7098 100644 --- a/computingservices/DocumentServices/services/dts/redactionsummary.py +++ b/computingservices/DocumentServices/services/dts/redactionsummary.py @@ -2,6 +2,7 @@ from rstreamio.message.schemas.redactionsummary import get_in_summary_object,get_in_summarypackage_object import json from collections import defaultdict +import traceback class redactionsummary(): @@ -25,48 +26,54 @@ def __getrangenumber(self, rangeval): def __packaggesummary(self, message, documentids, pageflags, programareas): try: - # print("\nInside __packaggesummary") + print("\nInside __packaggesummary") redactionlayerid = self.__getredactionlayerid(message) summarymsg = message.summarydocuments summaryobject = get_in_summary_object(summarymsg) ordereddocids = summaryobject.sorteddocuments stitchedpagedata = documentpageflag().getpagecount_by_documentid(message.ministryrequestid, ordereddocids) totalpagecount = self.__calculate_totalpages(stitchedpagedata) - # print("\ntotalpagecount",totalpagecount) + print("\n __packaggesummary stitchedpagedata",stitchedpagedata) + print("\n __packaggesummary totalpagecount",totalpagecount) if totalpagecount <=0: return _pageflags = self.__transformpageflags(pageflags) - # print("\n_pageflags",_pageflags) + print("\n_pageflags",_pageflags) summarydata = [] docpageflags = documentpageflag().get_documentpageflag(message.ministryrequestid, redactionlayerid, ordereddocids) deletedpages = self.__getdeletedpages(message.ministryrequestid, ordereddocids) skippages= [] pagecount = 0 - for docid in ordereddocids: - if docid in documentids: - docdeletedpages = deletedpages[docid] if docid in deletedpages else [] - docpageflag = docpageflags[docid] - for pageflag in _pageflags: - filteredpages = self.__get_pages_by_flagid(docpageflag["pageflag"], docdeletedpages, pagecount, pageflag["pageflagid"], message.category) - if len(filteredpages) > 0: - originalpagenos = [pg['originalpageno'] for pg in filteredpages] - docpagesections = documentpageflag().getsections_by_documentid_pageno(redactionlayerid, docid, originalpagenos) - docpageconsults = self.__get_consults_by_pageno(programareas, docpageflag["pageflag"], filteredpages) - pageflag['docpageflags'] = pageflag['docpageflags'] + self.__get_pagesection_mapping(filteredpages, docpagesections, docpageconsults) - skippages = self.__get_skippagenos(docpageflag['pageflag'], message.category) - pagecount = (pagecount+stitchedpagedata[docid]["pagecount"])-len(skippages) - # print("\n_pageflags1",_pageflags) - for pageflag in _pageflags: - _data = {} - if len(pageflag['docpageflags']) > 0: + try: + for docid in ordereddocids: + if docid in documentids: + docdeletedpages = deletedpages[docid] if docid in deletedpages else [] + docpageflag = docpageflags[docid] + for pageflag in _pageflags: + filteredpages = self.__get_pages_by_flagid(docpageflag["pageflag"], docdeletedpages, pagecount, pageflag["pageflagid"], message.category) + if len(filteredpages) > 0: + originalpagenos = [pg['originalpageno'] for pg in filteredpages] + docpagesections = documentpageflag().getsections_by_documentid_pageno(redactionlayerid, docid, originalpagenos) + docpageconsults = self.__get_consults_by_pageno(programareas, docpageflag["pageflag"], filteredpages) + pageflag['docpageflags'] = pageflag['docpageflags'] + self.__get_pagesection_mapping(filteredpages, docpagesections, docpageconsults) + skippages = self.__get_skippagenos(docpageflag['pageflag'], message.category) + pagecount = (pagecount+stitchedpagedata[docid]["pagecount"])-len(skippages) + print("\n_pageflags1",_pageflags) + for pageflag in _pageflags: _data = {} - _data["flagname"] = pageflag["header"].upper() - _data["pagecount"] = len(pageflag['docpageflags']) - _data["sections"] = self.__format_redaction_summary(pageflag["description"], pageflag['docpageflags'], message.category) - summarydata.append(_data) + if len(pageflag['docpageflags']) > 0: + _data = {} + _data["flagname"] = pageflag["header"].upper() + _data["pagecount"] = len(pageflag['docpageflags']) + _data["sections"] = self.__format_redaction_summary(pageflag["description"], pageflag['docpageflags'], message.category) + summarydata.append(_data) + except (Exception) as err: + traceback.print_exc() + print('error occured in __packaggesummary redaction dts service: ', err) return {"requestnumber": message.requestnumber, "data": summarydata} except (Exception) as error: + traceback.print_exc() print('error occured in redaction dts service: ', error) @@ -117,7 +124,7 @@ def __packagesummaryforcfdrequests(self, message, documentids): return {"requestnumber": message.requestnumber, "data": summarydata} except Exception as error: - print('Error occurred in redaction dts service: ', error) + print('CFD Error occurred in redaction dts service: ', error) def __calculate_range(self, mapped_flags, docids): diff --git a/computingservices/DocumentServices/services/redactionsummaryservice.py b/computingservices/DocumentServices/services/redactionsummaryservice.py index 9facce3e0..7193978bb 100644 --- a/computingservices/DocumentServices/services/redactionsummaryservice.py +++ b/computingservices/DocumentServices/services/redactionsummaryservice.py @@ -13,6 +13,7 @@ class redactionsummaryservice(): def processmessage(self,incomingmessage): summaryfilestozip = [] message = get_in_redactionsummary_msg(incomingmessage) + print('\n 1. get_in_redactionsummary_msg is : {0}'.format(message)) try: pdfstitchjobactivity().recordjobstatus(message,3,"redactionsummarystarted") summarymsg = message.summarydocuments @@ -23,22 +24,22 @@ def processmessage(self,incomingmessage): documenttypename= 'CFD_responsepackage_redaction_summary' else: documenttypename= category+"_redaction_summary" if category == 'responsepackage' else "redline_redaction_summary" - #print('documenttypename', documenttypename) + print('\n 2. documenttypename', documenttypename) upload_responses=[] pageflags = self.__get_pageflags(category) programareas = documentpageflag().get_all_programareas() messageattributes= json.loads(message.attributes) - #print("\nmessageattributes:",messageattributes) + print("\n 3. messageattributes:",messageattributes) divisiondocuments = get_in_summary_object(summarymsg).pkgdocuments - #print("\n divisiondocuments:",divisiondocuments) + print("\n 4. divisiondocuments:",divisiondocuments) for entry in divisiondocuments: #print("\n entry:",entry) if 'documentids' in entry and len(entry['documentids']) > 0 : - # print("\n entry['divisionid']:",entry['divisionid']) + print("\n 5. entry['divisionid']:",entry['divisionid']) divisionid = entry['divisionid'] documentids = entry['documentids'] formattedsummary = redactionsummary().prepareredactionsummary(message, documentids, pageflags, programareas) - #print("formattedsummary", formattedsummary) + print("\n 6. formattedsummary", formattedsummary) template_path='templates/'+documenttypename+'.docx' redaction_summary= documentgenerationservice().generate_pdf(formattedsummary, documenttypename,template_path) divisioname = None @@ -58,7 +59,7 @@ def processmessage(self,incomingmessage): s3uricategoryfolder = category s3uri = stitcheddocs3uri.split(s3uricategoryfolder+"/")[0] + s3uricategoryfolder+"/" filename =self.__get_summaryfilename(message.requestnumber, category, divisioname, stitcheddocfilename) - # print("\n filename:",filename) + print("\n redaction_summary.content length: {0}".format(len(redaction_summary.content))) uploadobj= uploadbytes(filename,redaction_summary.content,s3uri) upload_responses.append(uploadobj) if uploadobj["uploadresponse"].status_code == 200: @@ -72,6 +73,7 @@ def processmessage(self,incomingmessage): summaryfilestozip.append({"filename": uploadobj["filename"], "s3uripath":uploadobj["documentpath"]}) return summaryfilestozip except (Exception) as error: + traceback.print_exc() print('error occured in redaction summary service: ', error) pdfstitchjobactivity().recordjobstatus(message,4,"redactionsummaryfailed",str(error),"summary generation failed") return summaryfilestozip From c02545ff67777cd1527e6408181e6c0f6a516783 Mon Sep 17 00:00:00 2001 From: Abin Antony Date: Wed, 21 Aug 2024 11:46:11 -0700 Subject: [PATCH 03/18] #FOIMOD-3416 error handling for PSA-2024-41570 issue --- .../services/dts/redactionsummary.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/computingservices/DocumentServices/services/dts/redactionsummary.py b/computingservices/DocumentServices/services/dts/redactionsummary.py index 0a05f7098..7eb3cb022 100644 --- a/computingservices/DocumentServices/services/dts/redactionsummary.py +++ b/computingservices/DocumentServices/services/dts/redactionsummary.py @@ -42,6 +42,7 @@ def __packaggesummary(self, message, documentids, pageflags, programareas): print("\n_pageflags",_pageflags) summarydata = [] docpageflags = documentpageflag().get_documentpageflag(message.ministryrequestid, redactionlayerid, ordereddocids) + print("\n docpageflags",docpageflags) deletedpages = self.__getdeletedpages(message.ministryrequestid, ordereddocids) skippages= [] pagecount = 0 @@ -49,16 +50,18 @@ def __packaggesummary(self, message, documentids, pageflags, programareas): for docid in ordereddocids: if docid in documentids: docdeletedpages = deletedpages[docid] if docid in deletedpages else [] - docpageflag = docpageflags[docid] - for pageflag in _pageflags: - filteredpages = self.__get_pages_by_flagid(docpageflag["pageflag"], docdeletedpages, pagecount, pageflag["pageflagid"], message.category) - if len(filteredpages) > 0: - originalpagenos = [pg['originalpageno'] for pg in filteredpages] - docpagesections = documentpageflag().getsections_by_documentid_pageno(redactionlayerid, docid, originalpagenos) - docpageconsults = self.__get_consults_by_pageno(programareas, docpageflag["pageflag"], filteredpages) - pageflag['docpageflags'] = pageflag['docpageflags'] + self.__get_pagesection_mapping(filteredpages, docpagesections, docpageconsults) - skippages = self.__get_skippagenos(docpageflag['pageflag'], message.category) - pagecount = (pagecount+stitchedpagedata[docid]["pagecount"])-len(skippages) + if docpageflags is not None and docid in docpageflags.keys(): + docpageflag = docpageflags[docid] + for pageflag in _pageflags: + filteredpages = self.__get_pages_by_flagid(docpageflag["pageflag"], docdeletedpages, pagecount, pageflag["pageflagid"], message.category) + if len(filteredpages) > 0: + originalpagenos = [pg['originalpageno'] for pg in filteredpages] + docpagesections = documentpageflag().getsections_by_documentid_pageno(redactionlayerid, docid, originalpagenos) + docpageconsults = self.__get_consults_by_pageno(programareas, docpageflag["pageflag"], filteredpages) + pageflag['docpageflags'] = pageflag['docpageflags'] + self.__get_pagesection_mapping(filteredpages, docpagesections, docpageconsults) + skippages = self.__get_skippagenos(docpageflag['pageflag'], message.category) + if stitchedpagedata is not None: + pagecount = (pagecount+stitchedpagedata[docid]["pagecount"])-len(skippages) print("\n_pageflags1",_pageflags) for pageflag in _pageflags: _data = {} From e6b4f3bccc7ad5158e90ee5012eb86c84da3d246 Mon Sep 17 00:00:00 2001 From: Richard Qi Date: Wed, 21 Aug 2024 15:25:25 -0700 Subject: [PATCH 04/18] Fix observation #1 in FOIMOD-599 --- web/src/components/FOI/Home/Redlining.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/web/src/components/FOI/Home/Redlining.js b/web/src/components/FOI/Home/Redlining.js index 2fd39590e..72fdd0e66 100644 --- a/web/src/components/FOI/Home/Redlining.js +++ b/web/src/components/FOI/Home/Redlining.js @@ -1428,6 +1428,9 @@ const Redlining = React.forwardRef( let username = docViewer?.getAnnotationManager()?.getCurrentUser(); for (const entry in annotData) { let xml = parser.parseFromString(annotData[entry]); + // import redactions first, free text later, so translucent redaction won't cover free text + let xmlAnnotsChildren_redaction = []; + let xmlAnnotsChildren_others = []; for (let annot of xml.getElementsByTagName("annots")[0].children) { let txt = domParser.parseFromString( annot.getElementsByTagName("trn-custom-data")[0].attributes.bytes, @@ -1441,6 +1444,12 @@ const Redlining = React.forwardRef( (p) => p.pageNo - 1 === Number(originalPageNo) )?.stitchedPageNo - 1 )?.toString(); + if(annot.attributes.subject === "Redact") { + xmlAnnotsChildren_redaction.push(annot); + } else { + xmlAnnotsChildren_others.push(annot); + } + xml.getElementsByTagName("annots")[0].children = [...xmlAnnotsChildren_redaction, ...xmlAnnotsChildren_others]; } xml = parser.toString(xml); const _annotations = await annotManager.importAnnotations(xml); From 858b38f3a4d5491b3992386b555bac8361ab89e2 Mon Sep 17 00:00:00 2001 From: Aman-Hundal Date: Fri, 23 Aug 2024 13:12:58 -0700 Subject: [PATCH 05/18] Added AC 3 to ticket --- web/src/components/FOI/App.scss | 1 + .../FOI/Home/FOIPPASectionsModal.js | 15 ++++++- web/src/components/FOI/Home/Redlining.js | 41 ++++++++++++++++++- 3 files changed, 54 insertions(+), 3 deletions(-) diff --git a/web/src/components/FOI/App.scss b/web/src/components/FOI/App.scss index f518f21da..92b7f3fab 100644 --- a/web/src/components/FOI/App.scss +++ b/web/src/components/FOI/App.scss @@ -82,6 +82,7 @@ li.modal-message-list-item { margin: 6px 0; + font-size: 15px; } #state-change-dialog-title .MuiIconButton-root { diff --git a/web/src/components/FOI/Home/FOIPPASectionsModal.js b/web/src/components/FOI/Home/FOIPPASectionsModal.js index e78d83df7..48dab0601 100644 --- a/web/src/components/FOI/Home/FOIPPASectionsModal.js +++ b/web/src/components/FOI/Home/FOIPPASectionsModal.js @@ -32,7 +32,9 @@ export const FOIPPASectionsModal= ({ saveRedaction, defaultSections, saveDefaultSections, - clearDefaultSections + clearDefaultSections, + pageSelectionsContainNRDup, + setMessageModalOpen }) => { const [modalSortNumbered, setModalSortNumbered] = useState(false); @@ -101,6 +103,15 @@ export const FOIPPASectionsModal= ({ return b.count - a.count; } }; + + const handleSelectCodes = () => { + if (editRedacts) { + saveRedactions(); + } else { + saveRedaction(); + } + pageSelectionsContainNRDup ? setMessageModalOpen(true) : setMessageModalOpen(false); + } return( @@ -187,7 +198,7 @@ export const FOIPPASectionsModal= ({