def __init__(self, frame_pai, controller): super().__init__(frame_pai) self.controller = controller self.controller.requestRetrieveFriends() # LEMBRAR DE CRIAR METODOS QUE CARREGAMOS OS CONTATOS! self.currentChat = Models.LstMessages self.currentContactChat = Models.user() self.idUserSelected = self.currentContactChat.idd self.userFriendsList = Models.LstUsers() self.config_opcoes1(command=lambda: self.controller.loginActivity()) self.config_ajuda1(command=lambda: self.__raise_ajuda__()) self.config_ajuda2(command=lambda: self.__raise_sobre__()) self.botao_envia.config(command=lambda: self.__envia_msg__()) self.entr_msg.bind('<KeyRelease-Return>', lambda event: self.__envia_msg__()) self.contatos_treeview.bind('<<TreeviewSelect>>', lambda event: self.__retrieve_chat__()) #TODO MUDAR ESSA CHAMADA ABAIXO self.frame_chat.config(text='Seja bem vindo(a) ' + self.controller.session.currentUser.userName) self.add_contato_button.config(command=lambda: self.__add_contato__()) self.solicitations_button.config( command=lambda: self.FriendshipSolicitations()) self.entr_contatos.bind('<KeyRelease>', lambda event: self.__search_contacts__())
def __init__(self, controller): super().__init__() self.controller = controller self.lstRequests = Models.LstUsers() self.controller.requestFriendshipRequests() self.blockButton.config(command=lambda: self.blockUser()) self.aceptButton.config(command=lambda: self.aceptUser()) self.contatos_treeview.bind('<<TreeviewSelect>>', lambda event: self.bindTreeview())
def namesLike(self, user: Models.user, nameLike: str): tableName = 'friends_' + str(user.idd) nameLike = nameLike + '%' sql = 'SELECT ' \ 'id_friend, ' \ 'userName, u' \ 'serEmail ' \ 'FROM ' + tableName + \ ' INNER JOIN users ON (' + tableName + '.id_friend = users.id)' \ ' WHERE userName LIKE "' + nameLike + '" ;' lst_tupl = self.__execute_fetchall__(sql) lstUser = Models.LstUsers() if lst_tupl != []: for tupl in lst_tupl: user = Models.user() user.idd = int(tupl[0]) user.userName = tupl[1] user.userEmail = tupl[2] lstUser.append(user) return lstUser
def retrieveFriends(self, user: Models.user): id_user = user.idd tableName = 'friends_' + str(id_user) sql = 'SELECT id_friend, userName, userEmail, showNotification, dateAdd FROM ' + tableName + ' INNER JOIN users ON (' + tableName + '.id_friend = users.id) WHERE confirmation = 1;' lst_tupl = self.__execute_fetchall__(sql) if isinstance(lst_tupl, Exception): return lst_tupl elif lst_tupl is None: return Exception('Friends list not found') else: lstUser = Models.LstUsers() for elem in lst_tupl: friendUser = Models.user() friendUser.idd = int(elem[0]) friendUser.userName = elem[1] friendUser.userEmail = elem[2] friendUser.showNotification = elem[3] friendUser.dateAdd = elem[4] lstUser.append(friendUser) return lstUser
def fromJson(self, dictObj: dict): super().fromJson(dictObj) self.lstUsers = Models.LstUsers().fromJson(dictObj['lstUsers']) return self
def __init__(self, lstUsers: Models.LstUsers = Models.LstUsers()): super().__init__() self.lstUsers = lstUsers
def fromJson(self, dictObj: dict or list): super().fromJson(dictObj) self.namesLike = Models.LstUsers().fromJson(dictObj['namesLike']) return self
def __init__(self, namesLike: Models.LstUsers = Models.LstUsers()): super().__init__() self.namesLike = namesLike