Esempio n. 1
0
 def getAResource(self, rid):
     dao = ResourcesDAO()
     row = dao.getAResource(rid)
     if not row:
         return jsonify(Error="Resource Not Found"), 404
     else:
         request = self.build_resource_dict(row)
         return jsonify(Resource=request)
Esempio n. 2
0
 def getSuppliersByResourceId(self, rid):
     dao = ResourcesDAO()
     if not dao.getAResource(rid):
         return jsonify(Error="Resource Not Found"), 404
     suppliers_list = dao.getSuppliersByResourceId(rid)
     result_list = []
     for row in suppliers_list:
         result = self.build_user_dict(row)
         result_list.append(result)
     return jsonify(Suppliers=result_list)
Esempio n. 3
0
 def updateResource(self, rid, form):
     dao = ResourcesDAO()
     if not dao.getAResource(rid):
         return jsonify(Error="Resource not found."), 404
     else:
         if len(form) != 2:
             return jsonify(Error="Malformed update request"), 400
         else:
             rname = form['rname']
             rprice = form['rprice']
             if rname and rprice:
                 dao.updateResource(rid, rname, rprice)
                 result = self.build_resource_attributes(rid, rname, rprice)
                 return jsonify(Part=result), 200
             else:
                 return jsonify(
                     Error="Unexpected attributes in update request"), 400