Skip to content

Commit

Permalink
Merge pull request #852 from bcgov/main
Browse files Browse the repository at this point in the history
Redaction Summary fix
  • Loading branch information
divyav-aot authored Mar 7, 2024
2 parents e5214c4 + 952ff89 commit a975d91
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class SummaryPkgSchema(Schema):
class Meta:
unknown = EXCLUDE
divisionid = fields.Int(data_key="divisionid", allow_none=True)
documentids = fields.List(fields.Int())
documentids = fields.List(fields.Int(), allow_none=True)

class SummarySchema(Schema):
class Meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,33 @@ def processmessage(self,incomingmessage):
programareas = documentpageflag().get_all_programareas()
divisiondocuments = summarymsg.pkgdocuments
for entry in divisiondocuments:
divisionid = entry.divisionid
documentids = entry.documentids
formattedsummary = redactionsummary().prepareredactionsummary(message, documentids, pageflags, programareas)
template_path='templates/'+documenttypename+'.docx'
redaction_summary= documentgenerationservice().generate_pdf(formattedsummary, documenttypename,template_path)
messageattributes= message.attributes
#print("attributes length:",len(messageattributes))
if len(messageattributes)>1:
filesobj=(next(item for item in messageattributes if item.divisionid == divisionid)).files[0]
else:
filesobj= messageattributes[0].files[0]
stitcheddocs3uri = filesobj.s3uripath
stitcheddocfilename = filesobj.filename
s3uricategoryfolder= "oipcreview" if category == 'oipcreviewredline' else category
s3uri = stitcheddocs3uri.split(s3uricategoryfolder+"/")[0] + s3uricategoryfolder+"/"
filename = stitcheddocfilename.replace(".pdf","- summary.pdf")
uploadobj= uploadbytes(filename,redaction_summary.content, s3uri)
upload_responses.append(uploadobj)
if uploadobj["uploadresponse"].status_code == 200:
summaryuploaderror= False
summaryuploaderrormsg=""
else:
summaryuploaderror= True
summaryuploaderrormsg = uploadobj.uploadresponse.text
pdfstitchjobactivity().recordjobstatus(message,4,"redactionsummaryuploaded",summaryuploaderror,summaryuploaderrormsg)
summaryfilestozip.append({"filename": uploadobj["filename"], "s3uripath":uploadobj["documentpath"]})
if hasattr(entry, 'documentids') == True and len(entry.documentids) > 0:
divisionid = entry.divisionid
documentids = entry.documentids
formattedsummary = redactionsummary().prepareredactionsummary(message, documentids, pageflags, programareas)
template_path='templates/'+documenttypename+'.docx'
redaction_summary= documentgenerationservice().generate_pdf(formattedsummary, documenttypename,template_path)
messageattributes= message.attributes
#print("attributes length:",len(messageattributes))
if len(messageattributes)>1:
filesobj=(next(item for item in messageattributes if item.divisionid == divisionid)).files[0]
else:
filesobj= messageattributes[0].files[0]
stitcheddocs3uri = filesobj.s3uripath
stitcheddocfilename = filesobj.filename
s3uricategoryfolder= "oipcreview" if category == 'oipcreviewredline' else category
s3uri = stitcheddocs3uri.split(s3uricategoryfolder+"/")[0] + s3uricategoryfolder+"/"
filename = stitcheddocfilename.replace(".pdf","- summary.pdf")
uploadobj= uploadbytes(filename,redaction_summary.content, s3uri)
upload_responses.append(uploadobj)
if uploadobj["uploadresponse"].status_code == 200:
summaryuploaderror= False
summaryuploaderrormsg=""
else:
summaryuploaderror= True
summaryuploaderrormsg = uploadobj.uploadresponse.text
pdfstitchjobactivity().recordjobstatus(message,4,"redactionsummaryuploaded",summaryuploaderror,summaryuploaderrormsg)
summaryfilestozip.append({"filename": uploadobj["filename"], "s3uripath":uploadobj["documentpath"]})
return summaryfilestozip
except (Exception) as error:
print('error occured in redaction summary service: ', error)
Expand Down

0 comments on commit a975d91

Please sign in to comment.