def getGroupChatNameById(self, gid): dao = GroupChatDAO() result = dao.getGroupChatNameById(gid) if (result == None): return jsonify(Error="NOT FOUND"), 404 else: mapped_result = [] mapped_result.append(self.mapToDictIdtoName(result)) return jsonify(GroupChats=mapped_result)
def getGroupChatByOwner(self, uid): dao = GroupChatDAO() result = dao.getGroupChatByOwner(uid) if (result == None): return jsonify(Error="NOT FOUND"), 404 else: mapped_result = [] for r in result: mapped_result.append(self.mapToDictInfoByOwner(r)) return jsonify(GroupChatsByOwner=mapped_result)
def getGroupChatInfoByName(self, name): dao = GroupChatDAO() result = dao.getGroupChatInfoByName(name) if (result == None): return jsonify(Error="NOT FOUND"), 404 else: mapped_result = [] for r in result: mapped_result.append(self.mapToDictInfoByName(r)) return jsonify(GroupChats=mapped_result)
def getAllGroupChats(self): dao = GroupChatDAO() result = dao.getAllGroupChats() if result == None: return jsonify(Error="NOT FOUND"), 404 else: mapped_result = [] for r in result: mapped_result.append(self.mapToDict(r)) return jsonify(GroupChats=mapped_result)
def insertParticipant(self, form): dao = GroupChatDAO() if len(form) != 3: return jsonify(Error="Malformed insert request"), 400 else: GID = form['GID'] UID = form['UID'] CUID = form['CUID'] if GID and UID: validate = dao.validateContact(UID, CUID) if (validate == None): return jsonify(Error="Not a Contact"), 404 row = dao.insertParticipant(GID, CUID) if row == None: return jsonify(Error="Invalid Insert"), 404 else: #result = self.insert_NewChatGroup_dict(GID, UID) return jsonify(User="******") else: return jsonify( Error="Unexpected attributes in insert request"), 400
def insertNewChatGroup(self, form): dao = GroupChatDAO() if len(form) != 2: return jsonify(Error="Malformed insert request"), 400 else: GName = form['GName'] GCDate = datetime.datetime.today().strftime('%d-%m-%Y') UID = form['UID'] if GName and GCDate and UID: row = dao.insertNewChatGroup(GName, GCDate, UID) if row == None: return jsonify(Error="Invalid Insert"), 404 else: GID = row print('GID : ', GID) dao.insertParticipant(GID, UID) result = self.insert_NewChatGroup_dict(GName, GCDate, UID) return jsonify(User=result) else: return jsonify( Error="Unexpected attributes in insert request"), 400