Skip to content

Commit

Permalink
Merge pull request #1066 from bcgov/test-rook-AS-CFD-fixes
Browse files Browse the repository at this point in the history
Debug codes added
  • Loading branch information
aparna-aot authored Jul 25, 2024
2 parents 2b76ea2 + 1d1d316 commit c2ff9d9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
22 changes: 16 additions & 6 deletions api/reviewer_api/resources/foiflowmasterdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)
Expand All @@ -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(
Expand Down Expand Up @@ -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={
Expand All @@ -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"][:]
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion api/reviewer_api/utils/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -769,7 +768,6 @@ const useSaveRedlineForSignoff = (initDocInstance, initDocViewer) => {
render: `Start saving redline...`,
isLoading: true,
});
//setRedlineSinglePackage(res.issingleredlinepackage);
setIsSingleRedlinePackage(res.issingleredlinepackage);
let stitchDoc = {};

Expand All @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -1508,7 +1507,7 @@ const stampPageNumberRedline = async (
stitchObject,
PDFNet,
redlineStitchInfo[divisionid]["stitchpages"],
redlineSinglePackage
isSingleRedlinePackage
);
}
//OIPC - Special Block : End
Expand Down Expand Up @@ -1546,7 +1545,7 @@ const stampPageNumberRedline = async (
redlineIncompatabileMappings[divisionid],
redlineStitchInfo[divisionid]["s3path"],
divisionCountForToast,
redlineSinglePackage
isSingleRedlinePackage
);
},
(_err) => {
Expand Down

0 comments on commit c2ff9d9

Please sign in to comment.