def getReplies(self): dao = repliesDAO() replies = dao.getAllReplies() reply_list = [] for row in replies: reply_list.append(self.buildMessageDict(row)) return jsonify(Replies=reply_list)
def getRepliesbyDate(self, form): dao = repliesDAO() dateValue = form.get("timeStamp") name = dao.getAmountOfRepliesByDate(dateValue) reply_list = [] for row in name: reply_list.append(self.buildMessageDict(row)) return jsonify(Replies=reply_list)
def getReplies(self): dao = repliesDAO() replies = dao.getAllReplies() reply_list = [] for row in replies: reply_list.append(self.buildRepliesDict(row)) if not reply_list: return jsonify(Error='No replies'), 404 else: return jsonify(Replies=reply_list)
def getRepliesByMessage(self, mid): dao = repliesDAO() replies = dao.getReplies(mid) reply_list = [] for row in replies: reply_list.append(self.buildRepliesDict(row)) if not reply_list: return jsonify(Error='No replies to message'), 404 else: return jsonify(Replies=reply_list)
def addReply(self, form): if len(form) != 4: return jsonify(Error="Malformed post request"), 400 else: originID = form.get("originID") #replyID = form.get("replyID") uid = form.get("uid") gid = form.get("gid") #timeStamp = form.get("timeStamp") content = form.get("content") if originID and uid and gid and content: dao = repliesDAO() mdao = messagesDAO() mid = mdao.addMessage(uid, gid, content) dao.addReply(originID, mid) htids = self.hashtagCheck(content, mid) return self.getRepliesByMessage(mid) else: return jsonify( Error="Unexpected attributes in post request"), 400