Example #1
0
 def cadastrar(self, usuarios):
     print("Informe seus dados abaixo para fazer o cadastro!\n")
     self.typeuser = int(input("Tipo de usuário:\n<<1>> Funcionário\n<<2>> Cliente\n1 ou 2: "))
     self.username = input("\nNome (somente o primeiro nome): ")
     self.cpf = input("\nCPF (somente números): ")
     self.telefone = input("\nTelefone (DDD + número de telefone): ")
     self.email = input("\nE-mail (ex: [email protected]): ")
     self.senha = input("\nSenha: ")
     self.accept = int(input("\nVocê concorda com todos os Termos de Uso da aplicação?\n<<1>> Sim\n<<2>> Não\n1 ou 2: "))
     
     while(Validate.valide_typeuser(self, self.typeuser) != True):       
         self.typeuser = int(input("Tipo de usuário:\n<<1>> Funcionário\n<<2>> Cliente\n1 ou 2: "))
     while(Validate.valide_name(self, self.username) != True):       
         self.username = input("\nNome (somente o primeiro nome): ")
     while(Validate.valide_cpf(self, self.cpf) != True):
         self.cpf = input("\nCPF (somente números): ")
     while(Validate.valide_phone(self, self.telefone) != True):
         self.telefone = input("\nTelefone (DDD + número de telefone): ")
     while(Validate.valide_email(self, self.email) != True):
         self.email = input("\nE-mail (ex: [email protected]): ")
     while(Validate.valide_password(self, self.senha) != True):
         self.senha = input("\nSenha: ")
     while(Validate.valide_accept(self, self.accept) != True):
         self.accept = int(input("\nVocê concorda com todos os Termos de Uso da aplicação?\n<<1>> Sim\n<<2>> Não\n1 ou 2: "))
     
     if(Validate.valide_typeuser(self, self.typeuser) == True and Validate.valide_name(self, self.username) and Validate.valide_cpf(self, self.cpf) == True and Validate.valide_phone(self, self.telefone) == True and Validate.valide_email(self, self.email) == True and Validate.valide_password(self, self.senha) == True and Validate.valide_accept(self, self.accept) == True):
         print("Seu cadastro foi concluído com sucesso!")
         usuarios['typeuser'] = self.typeuser
         usuarios['name'] = self.username 
         usuarios['cpf'] = self.cpf 
         usuarios['phone'] = self.telefone
         usuarios['email'] = self.email
         usuarios['password'] = self.senha
         usuarios['agreement'] = self.accept
         with open("user.json", "a+", encoding="utf8") as json_file:
           json.dump(usuarios, json_file)
         time.sleep(2)