Skip to content

Commit

Permalink
Updated docreviewer to foiflow request fetch api
Browse files Browse the repository at this point in the history
  • Loading branch information
aparna-aot committed Jun 12, 2024
1 parent 05d9dd4 commit 535337e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
45 changes: 42 additions & 3 deletions request-management-api/request_api/resources/foirequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
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
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit 535337e

Please sign in to comment.