def login(): global username username = input("\nUsuario => ") not_crypted_pass = getpass.getpass(prompt='Senha => ', stream=None) # encoding the password md5pass = hashlib.md5(str(not_crypted_pass).encode('utf-8')) crypted_pass = md5pass.hexdigest() design_view.clear() Users.login(username, crypted_pass) if Users.status == 'logged': logged = 1 while logged == 1: design_view.clear() design_view.designLogged() command = input("\ninforme um comando [@comando] => ") if command == '@amigos': design_view.clear() friends_views.index() elif command == '@criartor': design_view.clear() tournaments_view.index() elif command == '@torneios': tournaments.list_tournament() elif command == '@users': design_view.clear() users_view.index() elif command == '@sair': logged = 0 else: print('\n comando inválido') time.sleep(2) elif Users.status == 'not logged': print("\n usuário ou senha inválidos :(") time.sleep(1)
def options_response(command): while command != '@voltar': if command == '@adicionar': design_view.clear() print("\n Enviar solicitação") searched_username = input("\n username do usuario => ") Friends.add_friend(searched_username) if Friends.status == 'sended': print("\n solicitação enviada com sucesso") time.sleep(3) break elif Friends.status == 'already_sended': print("\n solicitação já enviada") time.sleep(3) break elif Friends.status == 'user_dont_exists': print( "\n não foi possível encontrar nenhum usuário com este username" ) time.sleep(3) break elif command == '@solicitacoes': design_view.clear() print(" Solicitações recebidas\n") Friends.show_solicitations() if Friends.status == 'no_solicitations': print(" Sem solicitações no momento") time.sleep(4) break elif Friends.status == 'have_solicitations': print(" NAME USERNAME USER_TYPE") for solicitation in Friends.show_solicitations(): print(" {} {} {}".format( solicitation[0][0], solicitation[0][1], solicitation[0][2])) friend_accept = input("\n username para aceitar => ") if friend_accept: Friends.accept_solicitations(friend_accept) if Friends.status == 'accepted': print( "\n Solicitação aceita\n Agora, {} é seu mais novo amigo :)" .format(friend_accept)) time.sleep(3) elif Friends.status == 'user_dont_sended_solicitation': print( "\n o usuário informado não está pedindo solicitação de amizade" ) time.sleep(3) elif Friends.status == 'user_dont_exists': print( "\n não foi possível encontrar nenhum usuário com este username" ) time.sleep(3) else: break else: print('\n comando inválido') time.sleep(2) break
def create_tournament(): created_at = datetime.today() name_tournament = input('Nome do torneio => ') type_tournament = input('Diga o tipo de torneio que deseja criar => ') category_tournament = input('Categoria do torneio => ') description = input('Descrição do torneio => ') participants = 0 room_ = input('A sala será aberta ou fechada? ') if room_ == 'fechada': password_room_tournment = input('Insira a senha do torneio => ') bd.cursor.execute( """ INSERT INTO tournament(name,category,room,password_tournament,type_tournament,description,created_at,participants) values (%s,%s,%s,%s,%s,%s,%s,%s) """, (name_tournament, category_tournament, room_.upper(), password_room_tournment, type_tournament, description, created_at, participants)) bd.connection.commit() print('Torneio registrado.') time.sleep(1) design_view.clear() design_view.designLogged() elif room_ == 'aberta': bd.cursor.execute( """ INSERT INTO tournament(name,category,room,type_tournament,description,created_at,participants) values (%s,%s,%s,%s,%s,%s,%s) """, (name_tournament, category_tournament, room_.upper(), type_tournament, description, created_at, participants)) bd.connection.commit() print('Torneio registrado.') time.sleep(1) design_view.clear() design_view.designLogged()
# @@@@@ IMPORTS @@@@@@ import random import time import sys from datetime import datetime # @@ FOLDERS @@ from views import login_view, sign_up_view, design_view,tournaments # main application # loop menu global activeApp activeApp = 1 while activeApp == 1: design_view.clear() design_view.designMenu() commands = input("\ninforme um comando [@comando] => ") if commands == '@entrar': # form area design_view.clear() login_view.login() elif commands == '@cadastrar': # form area design_view.clear() sign_up_view.sign_up() elif commands == '@admin': # form area design_view.clear() sign_up_view.sign_up_admin() elif commands == '@sair':