Пример #1
0
 def deleteUser(self, uid):
     dao = UserDAO ()
     if not dao.getUserById (uid):
         return jsonify (Error="User not found."), 404
     else:
         dao.delete (uid)
         return jsonify (DeleteStatus="OK"), 200
Пример #2
0
    def updateUser(self, userDic, userAddressDic):
        dao = UserDAO ()
        if not dao.getUserById (userDic['uid']):
            return jsonify (Error="Resource not found."), 404
        else:
            if len (userDic) != 4 & len (userAddressDic) != 7:
                return jsonify (Error="Malformed update request"), 400
            else:
                uid = userDic['uid']
                uname = userDic['uname']
                ulast = userDic['ulast']
                utype = userDic['utype']
                uaddress = userAddressDic['uaddress']
                ucity = userAddressDic['ucity']
                uregion = userAddressDic['uregion']
                uzip = userAddressDic['uzip']
                ustate = userAddressDic['ustate']
                loclat = userAddressDic['loclat']
                loclon = userAddressDic['loclon']

                if uid and uname and ulast and utype and uaddress and ucity and uregion and uzip and ustate and loclat and loclon:
                    uidout = dao.update (uid, uname, ulast, utype, uaddress, ucity, uregion, uzip, ustate, loclat, loclon)
                    result = self.build_alluserinfo_dict2 (uidout, uname, ulast, utype, uaddress, ucity, uregion, uzip,
                                                          ustate, loclat, loclon)
                    return jsonify (User=result), 201
                else:
                    return jsonify (Error="Unexpected attributes in put request"), 400
Пример #3
0
 def getUserById(self, uid):
     dao = UserDAO()
     row = dao.getUserById(uid)
     if not row:
         return jsonify(Error="User Not Found"), 404
     else:
         result = self.build_alluserinfo_dict(row)
     return jsonify(result)