diff --git a/request-management-api/request_api/resources/foirequest.py b/request-management-api/request_api/resources/foirequest.py index 472e08f40..fa537fe8e 100644 --- a/request-management-api/request_api/resources/foirequest.py +++ b/request-management-api/request_api/resources/foirequest.py @@ -56,7 +56,7 @@ def get(foirequestid,foiministryrequestid,usertype = None): jsondata = {} statuscode = 200 if (AuthHelper.getusertype() == "iao") and (usertype is None or (usertype == "iao")): - jsondata = requestservice().getrequestdetails(foirequestid,foiministryrequestid) + jsondata = requestservice().getrequest(foirequestid,foiministryrequestid) assignee = jsondata['assignedTo'] isrestricted = jsondata['iaorestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['iaorestricteddetails']) else False if(canrestictdata(foiministryrequestid,assignee,isrestricted,False)): @@ -287,7 +287,7 @@ class FOIRequestByMinistryId(Resource): @auth.require def get(ministryrequestid,usertype=None): try : - return FOIRequest.get(requestservice().getrequestid(ministryrequestid), ministryrequestid, usertype) + return FOIRequestForDocReviewer.get(requestservice().getrequestid(ministryrequestid), ministryrequestid, usertype) except ValueError: return {'status': 500, 'message':"Invalid Request"}, 500 except BusinessException as exception: @@ -322,4 +322,43 @@ def post(foirequestid,foiministryrequestid,section): except KeyError as error: return {'status': False, 'message': CUSTOM_KEYERROR_MESSAGE + str(error)}, 400 except BusinessException as exception: - return {'status': exception.status_code, 'message':exception.message}, 500 \ No newline at end of file + return {'status': exception.status_code, 'message':exception.message}, 500 + + +@cors_preflight('GET,OPTIONS') +class FOIRequestForDocReviewer(Resource): + """Retrieve foi request for opened request - Used + in docreviewer""" + + @staticmethod + @TRACER.trace() + @cross_origin(origins=allowedorigins()) + @auth.require + @auth.ismemberofgroups(getrequiredmemberships()) + def get(foirequestid,foiministryrequestid,usertype = None): + try : + jsondata = {} + statuscode = 200 + if (AuthHelper.getusertype() == "iao") and (usertype is None or (usertype == "iao")): + jsondata = requestservice().getrequestdetails(foirequestid,foiministryrequestid) + assignee = jsondata['assignedTo'] + isrestricted = jsondata['iaorestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['iaorestricteddetails']) else False + if(canrestictdata(foiministryrequestid,assignee,isrestricted,False)): + jsondata = {} + statuscode = 401 + elif usertype is not None and usertype == "ministry" and AuthHelper.getusertype() == "ministry": + jsondata = requestservice().getrequestdetailsforministry(foirequestid,foiministryrequestid,AuthHelper.getministrygroups()) + assignee = jsondata['assignedministryperson'] + isrestricted = jsondata['ministryrestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['ministryrestricteddetails']) else False + if(canrestictdata_ministry(foiministryrequestid,assignee,isrestricted)): + jsondata = {} + statuscode = 401 + else: + statuscode = 401 + return jsondata , statuscode + except ValueError: + return {'status': 500, 'message':"Invalid Request Id"}, 500 + except KeyError as error: + return {'status': False, 'message': CUSTOM_KEYERROR_MESSAGE + str(error)}, 400 + except BusinessException as exception: + return {'status': exception.status_code, 'message':exception.message}, 500 \ No newline at end of file diff --git a/request-management-api/request_api/services/foirequest/requestservicegetter.py b/request-management-api/request_api/services/foirequest/requestservicegetter.py index 1e7410772..61e50b09a 100644 --- a/request-management-api/request_api/services/foirequest/requestservicegetter.py +++ b/request-management-api/request_api/services/foirequest/requestservicegetter.py @@ -119,11 +119,11 @@ def getrequestdetails(self,foirequestid, foiministryrequestid): payment = paymentservice().getpayment(foirequestid, foiministryrequestid) if approvedcfrfee is not None and approvedcfrfee != {}: requestdetails['cfrfee'] = approvedcfrfee - _totaldue = float(approvedcfrfee['feedata']['actualtotaldue']) if float(approvedcfrfee['feedata']['actualtotaldue']) > 0 else float(approvedcfrfee['feedata']['estimatedtotaldue']) + _totaldue = float(approvedcfrfee['feedata']['actualtotaldue']) if 'actualtotaldue' in approvedcfrfee['feedata'] and float(approvedcfrfee['feedata']['actualtotaldue']) > 0 else float(approvedcfrfee['feedata']['estimatedtotaldue']) _balancedue = _totaldue - (float(cfrfee['feedata']['amountpaid']) + float(approvedcfrfee['feedata']['feewaiveramount'])) requestdetails['cfrfee']['feedata']['amountpaid'] = cfrfee['feedata']['amountpaid'] requestdetails['cfrfee']['feedata']["balanceDue"] = '{:.2f}'.format(_balancedue) - if approvedcfrfee['feedata']['actualtotaldue']: + if 'actualtotaldue' in approvedcfrfee['feedata'] and approvedcfrfee['feedata']['actualtotaldue']: requestdetails['cfrfee']['feedata']["totalamountdue"] = '{:.2f}'.format(requestdetails['cfrfee']['feedata']["actualtotaldue"]) else: requestdetails['cfrfee']['feedata']["totalamountdue"] = '{:.2f}'.format(requestdetails['cfrfee']['feedata']["estimatedtotaldue"])