def run(cls):
        print("Welcome to Hospital Hack Bulgaria!")
        options = """
Do you want to sign in or sign up?
Options:
1 - sign in
2 - sign up
3 - exit
        """
        print(options)
        start_option = input()
        # TODO check if the option number is correct
        username = input('Username:> ')
        password = input('Password:> ')
        if start_option == '1':

            # TODO hide password
            current_user = MainController.sign_in(username, password)
            if current_user:
                MainMenu.show_options(current_user)
            else:
                print("Wrong username or password!")
                sys.exit(1)
        elif start_option == '2':
            # TODO hide password
            second_password = input('Second Password:>')
            try:
                current_user = MainController.sign_up(
                    username, password, second_password)
            except UserAlreadyExistsError:
                print('Sign up failed! User already exists!')
                sys.exit(1)
            except DatabaseConnectionError:
                print('Sign up failed! Server error! Try again')
                sys.exit(1)
            except PasswordsDontMatchError:
                print('Sign up failed! Password don\'t match! Try again')
                sys.exit(1)
            else:
                MainMenu.show_options(current_user)
        else:
            sys.exit(1)
Ejemplo n.º 2
0
 def run(cls):
     print('Welcome to the Hospital!')
     options = """
         'Do you want to sign in or sign up?
         1 - sign in
         2 - sign up
         3 - exit
     """
     print(options)
     start_option = input()
     # TODO check if the num is ok
     username = input('Username:> ')
     password = input('Password:> ')
     if start_option == '1':
         # TODO hide password
         is_signed = MainController.sign_in(username, password)
         if is_signed:
             MainMenu.show_options(is_signed)
         else:
             print('Wrong username or password!')
             sys.exit(1)
     elif start_option == '2':
         #TODO hide pass
         second_password = input('Second password:> ')
         status = input('Are you a Patient or a Doctor?> ')
         
         try:
             current_user = MainController.sign_up(username, password, second_password, status)
         except UserAlreadyExists:
             print('Sign up failed! User already exists')
             sys.exit(1)
         except DatabaseConnectionError:
             print('Sign up failed! Server error! Try again!')
             sys.exit(1)
         except PasswordsDontMatchError:
             print('Sign up failed! Passwords do not match!')
             sys.exit(1)
         
         MainMenu.show_options(current_user)
     else:
         sys.exit(1)
Ejemplo n.º 3
0
    def run(cls):
        print("Welcome to Hospital Hack Bulgaria!")
        options = """
Do you want to sign in or sign up?
Options:
1 - sign in
2 - sign up
3 - exit
        """
        print(options)
        start_option = input()
        if start_option == '3':
            return
        # TODO check if the option number is correct
        username = input('Username:> ')
        password = input('Password:> ')
        if start_option == '1':

            # TODO hide password
            current_user = MainController.sign_in(username, password)
            if current_user:
                MainMenu.show_options(current_user)
            else:
                print("Wrong username or password!")
                sys.exit(1)
        elif start_option == '2':
            # TODO hide password
            second_password = input('Confirm Password:>')
            status = input('You are doctor or patient:> ')
            if status == 'doctor':
                title = input('Title:> ')
                try:
                    current_user = MainController.sign_up(username,
                                                          password,
                                                          second_password,
                                                          status=status,
                                                          title=title)
                except UserAlreadyExistsError:
                    print('Sign up failed! User already exists!')
                    sys.exit(1)
                except DatabaseConnectionError:
                    print('Sign up failed! Server error! Try again')
                    sys.exit(1)
                except PasswordsDontMatchError:
                    print('Sign up failed! Password don\'t match! Try again')
                    sys.exit(1)
                else:
                    MainMenu.show_options(current_user)
            elif status == 'patient':
                illness = input('Illness:> ')
                try:
                    current_user = MainController.sign_up(username,
                                                          password,
                                                          second_password,
                                                          status=status,
                                                          illness=illness)
                except UserAlreadyExistsError:
                    print('Sign up failed! User already exists!')
                    sys.exit(1)
                except DatabaseConnectionError:
                    print('Sign up failed! Server error! Try again')
                    sys.exit(1)
                except PasswordsDontMatchError:
                    print('Sign up failed! Password don\'t match! Try again')
                    sys.exit(1)
                else:
                    MainMenu.show_options(current_user)
            else:
                print('-----In ELse------')
        else:
            sys.exit(1)
Ejemplo n.º 4
0
                    sys.exit(1)
                else:
                    MainMenu.show_options(current_user)
            elif status == 'patient':
                illness = input('Illness:> ')
                try:
                    current_user = MainController.sign_up(username,
                                                          password,
                                                          second_password,
                                                          status=status,
                                                          illness=illness)
                except UserAlreadyExistsError:
                    print('Sign up failed! User already exists!')
                    sys.exit(1)
                except DatabaseConnectionError:
                    print('Sign up failed! Server error! Try again')
                    sys.exit(1)
                except PasswordsDontMatchError:
                    print('Sign up failed! Password don\'t match! Try again')
                    sys.exit(1)
                else:
                    MainMenu.show_options(current_user)
            else:
                print('-----In ELse------')
        else:
            sys.exit(1)


if __name__ == '__main__':
    print(MainController.sign_in('maha', '12334aaa'))
Ejemplo n.º 5
0
    def run(cls):
        print(HospitalConstants.start_menu_options)
        start_option = input("Option: ")

        if start_option == '1':

            # it is okay to actually make the sign in method to return true or false
            # we can make it return either the whole object, the title (doctor or patient) ot None

            username = input("Username: "******"Password: "******"Password does not match criteria!")
                sys.exit(1)
            except DatabaseConnectionError:
                print("Sign in failed! Try again!")
                sys.exit(1)
            else:
                if current_user:
                    MainMenu.show_options(current_user)
                else:
                    print("Wrong username or password!")
                    sys.exit(1)

        elif start_option == '2':
            print("Are you a doctor or a patient?")
            title = input("Position: ")

            if title not in ["doctor", "patient"]:
                print("Unknown positon! Try again!")
                sys.exit(1)

            username = input("Username: "******"Full name: ")
            password = getpass.getpass("Password: "******"Repeat password: "******"doctor":
                    position = input("Enter your position: ")
                    user_info.update({"position": position})

                elif title == "patient":
                    condition = input("Enter your condition: ")
                    age = input("Enter your age: ")
                    user_info.update({"condition": condition, "age": age})

                current_user = MainController.connect_tables(
                    title, username, user_info)

            except UserAlreadyExistsError:
                print("Sign up failed! Username already taken!")
                sys.exit(1)
            except DatabaseConnectionError:
                print("Sign up failed! Try again!")
                sys.exit(1)
            except PasswordsDontMatchError:
                print("Sign up failed! Passwords don\'t match! ")
                sys.exit(1)
            except InvalidPasswordError:
                print("Passwords does not match criteria!")
                sys.exit(1)
            else:
                MainMenu.show_options(title)

        else:
            sys.exit(1)