def updatePerson(self, pid, form): dao = PersonDAO() if not dao.getPersonById(pid): return jsonify(Error="Person not found."), 404 else: if len(form) != 7: return jsonify(Error="Malformed update request"), 400 else: pfirstname = form['first_name'] pmiddleinitial = form['middle_initial'] plastname = form['last_name'] email = form['email'] plocation = form['location_of_p'] pphone = form['phone'] loginID = form['login_id'] if pfirstname and plastname and pmiddleinitial and pphone and loginID and plocation and email: dao.update(pid, pfirstname, pmiddleinitial, plastname, email, plocation, pphone, loginID) result = {} result['p_id'] = pid result['first_name'] = pfirstname result['middle_initial'] = pmiddleinitial result['last_name'] = plastname result['email'] = email result['location_of_p'] = plocation result['phone'] = pphone result['login_id'] = loginID return jsonify(Person=result), 200 else: return jsonify( Error="Unexpected attributes in update request"), 400
def updatePerson(self, perid, form): dao = PersonDAO() updated_person = dao.update(perid, form) return jsonify(updated_person), 200