def updateUser(self, uid, form): dao = UserDao() if not dao.getUserById(uid): # hardcoded, delete later return jsonify(Error="User not found."), 404 else: if len(form) != 7: return jsonify(Error="Malformed update request."), 400 else: try: aid = form['address_id'] rid = form['role_id'] fname = form['first_name'] lname = form['last_name'] email = form['email'] password = form['password'] phone_number = form['phone_number'] if fname and lname and email and password and phone_number and aid and rid: dao.update(fname, lname, email, password, rid, aid, phone_number, uid) result = self.__build_user_attributes( uid, aid, rid, fname, lname, email, password, phone_number) return jsonify(User=result), 200 else: return jsonify( Error="Attributes must not be null"), 400 except Exception as e: return jsonify( Error=f'Unexpected attributes in put request; {e}' ), 400
def getUserByID(self, uid): dao = UserDao() row = dao.getUserById(uid) if not row: return jsonify(Error="User Not Found"), 404 else: user = self.__build_user_dict(row) return jsonify(User=user)