Example #1
0
 def getRequestsByResourceId(self, resid):
     requests_dao = RequestData()
     row = requests_dao.getRequestById(resid)
     if not row:
         return jsonify(Error="Request Not Found"), 404
     else:
         result = self.build_request_dict(row)
     return jsonify(Request=result)
Example #2
0
 def getAllRequestedResourcesByKeyword(self, keyword):
     requests_dao = RequestData()
     requests_list = requests_dao.getAllRequestedResourcesByKeyword(keyword)
     result_list = []
     for row in requests_list:
         result = self.build_requested_resources_dict(row)
         result_list.append(result)
     return jsonify(Requests=result_list)
Example #3
0
 def getRequestsInfoByVictimId(self, vid):
     requests_dao = RequestData()
     row = requests_dao.getRequestsInfoByVictimId(vid)
     if not row:
         return jsonify(Error="Request Not Found"), 404
     else:
         result = self.build_request_info_dict(row)
     return jsonify(Request=result)
Example #4
0
 def getAllRequests(self):
     requests_dao = RequestData()
     requests_list = requests_dao.getAllRequests()
     result_list = []
     for row in requests_list:
         result = self.build_request_dict(row)
         result_list.append(result)
     return jsonify(Requests=result_list)
Example #5
0
    def insertRequest(self, form):
        if form and len(form) == 3:
            date_submited = form['date_submited']
            resource_id = form['resource_id']
            victim_id = form['victim_id']

            if date_submited and resource_id and victim_id:
                dao = RequestData()
                request_id = dao.insert(date_submited, resource_id, victim_id)
                result = {}
                result["request_id"] = request_id
                result["date_submited"] = date_submited
                result["resource_id"] = resource_id
                result["victim_id"] = victim_id
                return jsonify(Request=result), 201
            else:
                return jsonify(Error="Malformed post request1")
        else:
            return jsonify(Error="Malformed post request2")