def __init__(self): self.clientHandler = ClientHandler.ClientRequestManager(self) self.currentUser = Models.user() self.viewController = ViewController.MainViewController(self) self.viewController.loginActivity() self.viewController.mainloop()
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 __comando_B1__(self): user = Models.user() user.userName = self.entr1.retorna_entr() user.userEmail = self.entrMail.retorna_entr() user.password = self.entr2.retorna_entr() password2 = self.entr3.retorna_entr() if user.password != password2: self.messagebox_info('Cadastro', 'As senhas não conferem!') self.entr2.limpa_entr() self.entr3.limpa_entr() else: self.controller.requestNewUser(user)
def retrieveUser(self, id_user): id_user = self.__strip_id__(id_user, tipo='str') sql = 'SELECT userEmail, userName FROM users WHERE id = ' + id_user + ';' tupl = self.__execute_fetchone__(sql) if tupl != None: user = Models.user() user.userEmail = tupl[0] user.userName = tupl[1] user.idd = int(id_user) return user else: return Exception('User not found')
def searchUser(self, userEmail: str): sql = 'SELECT id, userName FROM users WHERE userEmail = "' + userEmail + '" ;' commitFeedback = self.__execute_fetchone__(sql) if isinstance(commitFeedback, Exception): return commitFeedback elif commitFeedback != None: user = Models.user() user.userEmail = userEmail user.userName = commitFeedback[1] user.idd = int(commitFeedback[0]) return user else: return Exception('Usuário não encontrado!')
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 __init__(self, currentUser: Models.user = Models.user()): super().__init__() self.user = currentUser
def fromJson(self, dictObj: dict): super().fromJson(dictObj) self.user = Models.user().fromJson(dictObj['user']) return self
def __init__(self, user: Models.user = Models.user()): super().__init__() self.user = user
def fromJson(self, dictObj: dict): super().fromJson(dictObj) self.friendship = Models.Friendship().fromJson(dictObj['friendship']) self.recipUser = Models.user().fromJson(dictObj['recipUser']) self.senderUser = Models.user().fromJson(dictObj['senderUser']) return self
def fromJson(self, dictObj: dict): super().fromJson(dictObj) self.friendship = Models.user().fromJson(dictObj['friendship']) return self
def __init__(self, senderUser: Models.user = Models.user(), recipUser: Models.user = Models.user()): super().__init__() self.senderUser = senderUser self.recipUser = recipUser
def fromJson(self, dictObj: dict or list): super().fromJson(dictObj) self.namesLike = dictObj['namesLike'] self.user = Models.user().fromJson(dictObj['user']) return self
def __init__(self, currentUser: Models.user = Models.user(), nameLike: str = ''): super().__init__() self.namesLike = nameLike self.user = currentUser
def fromJson(self, dictObj: dict) -> object: super().fromJson(dictObj) self.friendEmail = dictObj['friendEmail'] self.user = Models.user().fromJson(dictObj['user']) return self
def __init__(self, currentUser: Models.user = Models.user(), friendEmail: str = ''): super().__init__() self.friendEmail = friendEmail self.user = currentUser