def getAllGroups(self): dao = groupDAO() result = dao.getAllGroups() mapped_result = [] for r in result: mapped_result.append(self.mapToDict(r)) return jsonify(Group=mapped_result)
def getGroupByCreation(self, gcreation): dao = groupDAO() result = dao.getGroupByCreation(gcreation) mapped_result = [] if not result: return jsonify(Error="NOT FOUND"), 404 else: for r in result: mapped_result.append(self.mapToDict(r)) return jsonify(Group=mapped_result)
def getGroupsByName(self, gname): dao = groupDAO() result = dao.getGroupsByName(gname) mapped_result = [] if not result: return jsonify(Error="NOT FOUND"), 404 else: for r in result: mapped_result.append(self.mapToDict(r)) return jsonify(Group=mapped_result)
def getByUserId(self, uid): dao = groupDAO() result = dao.getByUserId(uid) mapped_result = [] if not result: return jsonify(Error="NOT FOUND"), 404 else: for r in result: mapped_result.append(self.mapToDict(r)) return jsonify(Group=mapped_result)
def getMessagesByGroupId(self, gid): dao = groupDAO() result = dao.getMessagesByGroupId(gid) mapped_result = [] if not result: return jsonify(Error="NOT FOUND"), 404 else: for r in result: mapped_result.append(self.mapGroupMessagesToDict(r)) return jsonify(GroupMessages=mapped_result)
def insertCredentialsJSON(self, json): gname = json.get('gName') gdescription = json.get('gdescription') gcreation = json.get('gcreation') adminId = json.get('gadminID') print("GroupHandler") print(gname) print(gdescription) print(gcreation) print(adminId) if gname and gcreation and gdescription and adminId: gid = groupDAO().insert(gname, gdescription, gcreation, adminId) mapped_result = self.buildGroupDict(gid, gname, gdescription, gcreation, adminId) return jsonify(Group=mapped_result), 201 else: return jsonify(Error="Unexpected attributes in post request"), 404