def getUserAllReaction(self, uid): dao = UserDao() user_reaction_list = dao.getUserReaction(uid) result_list = [] for row in user_reaction_list: result = self.build_user_reaction_dict(row) result_list.append(result) return jsonify(ReactionsByUser=result_list)
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)
def getAllUser(self): dao = UserDao() user_list = dao.getAllUser() result_list = [] for row in user_list: result = self.build_user_dict(row) result_list.append(result) return jsonify(User=result_list)
def updateUser(self, uid, form): dao = UserDao() user = dao.update(uid) if not user: return jsonify(Error="USER NOT FOUND"), 404 result = self.build_user_dict(user) return jsonify(User=result), 200
def getPostsFromUser(self, uid): posts = UserDao().postsFromUser(uid) if not posts: return jsonify(Error="NOT FOUND POSTS FROM USER"), 404 result = [] for p in posts: result.append(self.build_post_dict(p)) return jsonify(PostsFromUser=result)
def getUsername(self, uid): username = UserDao().getUsername(uid) if not username: return jsonify(Error="USER NOT FOUND"), 404 result = {} result['username'] = username return jsonify(Username=result)
def getCredentials(self): dao = UserDao() result = dao.getCredentials('', '') return jsonify(User=self.build_credential_dict(result))
def insertUser(self): dao = UserDao() user = dao.insertUser() result = self.build_user_dict(user) return jsonify(User=result), 201