Пример #1
0
 def updatePart(self, pid, form):
     dao = PartsDAO()
     if not dao.getPartById(pid):
         return jsonify(Error="Part Not Found."), 404
     else:
         if len(form) != 2:
             return jsonify(Error="Column Amount in Malform."), 400
         else:
             res_type = form['res_type']
             unit_price = form['unit_price']
             if res_type and unit_price:
                 dao.update(pid, res_type, unit_price)
                 result = self.build_part_attributes(
                     pid, res_type, unit_price)
                 return jsonify(Part=result), 200
             else:
                 return jsonify(
                     Error="Unexpected Attributes for Update Request."), 400
Пример #2
0
 def updatePart(self, pid, form):
     dao = PartsDAO()
     if not dao.getPartById(pid):
         return jsonify(Error="Part not found."), 404
     else:
         if len(form) != 4:
             return jsonify(Error="Malformed update request"), 400
         else:
             pname = form['pname']
             pprice = form['pprice']
             pmaterial = form['pmaterial']
             pcolor = form['pcolor']
             if pcolor and pprice and pmaterial and pname:
                 dao.update(pid, pname, pcolor, pmaterial, pprice)
                 result = self.build_part_attributes(
                     pid, pname, pcolor, pmaterial, pprice)
                 return jsonify(Part=result), 200
             else:
                 return jsonify(
                     Error="Unexpected attributes in update request"), 400
Пример #3
0
 def updateResourceJson(self, Partsid, json):
     dao = PartsDAO()
     if not dao.getPartsById(Partsid):
         return jsonify(Error="Parts not found."), 404
     else:
         Partsmaterial = json['PartsMaterial']
         Partscolor = json['PartsColor']
         Partsdescription = json['PartsDescription']
         if Partsmaterial and Partscolor and Partsdescription:
             dao.update(Partsid, Partsmaterial, Partscolor,
                        Partsdescription)
             resourceid = dao.getResourceIDByPartsID(Partsid)
             result = self.build_parts_attributes(Partsid, Partsmaterial,
                                                  Partscolor,
                                                  Partsdescription,
                                                  resourceid)
             return jsonify(Parts=result), 400
         else:
             return jsonify(
                 Error="Unexpected attributes in update request"), 400