예제 #1
0
    def display(self):
        print(f'\nWelcome, {self.__context.user.username}!')
        
        input_func = get_option_input()

        def get_input():
            print(self.__menu_heading)
            print(self.__options)
            
            selected_option = input_func('\nEnter option\'s id: ')
            if selected_option not in self.__next_menus.keys():
                raise UserInputOptionException
            return selected_option

        while True:
            selected_option = self.input_secure_wrap(get_input)

            try:
                next_menu = self.__next_menus[selected_option](
                    self.__user_controller,
                    self.__profile_controller,
                    self.__post_controller
                )
                next_menu.display()
            except ExitFromMenuException:
                return
예제 #2
0
    def show(self):
        print(self.__header)

        input_func = get_option_input()

        def get_input():
            selected_option = input_func('Enter option: ')
            if selected_option not in self.__next_menus.keys():
                raise UserInputOptionException
            return selected_option

        while True:
            username = input('Enter username: '******'Enter password: '******'status'] == 'success':
                menu_context = Context(context['user'], context['profile'])
                next_menu = MainMenu(self.__user_controller,
                                     self.__profile_controller,
                                     self.__post_controller)
                next_menu.show()
            elif context['status'] == 'failed':
                print('Login error!')
                print(self.__options)

                selected_option = self.input_secure_wrap(get_input)

                try:
                    self.__next_menus[selected_option](
                        self.__user_controller, self.__profile_controller,
                        self.__post_controller)
                except ExitFromMenuException:
                    return
예제 #3
0
    def display(self):
        option_input_func = get_option_input()
        username_input_func = get_username_input()
        password_input_func = get_password_input()

        def get_option():
            print(self.__menu_heading)
            print(self.__options)

            selected_option = option_input_func('\nEnter option\'s id: ')
            if selected_option not in self.__next_menus.keys():
                raise UserInputOptionException
            return selected_option

        def get_username():
            print(self.__menu_heading)
            return username_input_func(
                'Enter your new account\'s username (username must start with a letter and be at least 5 characters long): '
            )

        def get_password():
            print(self.__menu_heading)
            return password_input_func(
                'Enter your new account\'s password (password must be at least 8 characters long): '
            )

        while True:
            username = self.input_secure_wrap(get_username)
            password = self.input_secure_wrap(get_password)

            if self.__user_controller.read_user_by_username(username):
                print(
                    '\n>>> Entered username is already occupied by another user. Try a different username <<<'
                )
                continue

            selected_option = self.input_secure_wrap(get_option)
            try:
                self.__next_menus[selected_option]()
            except ExitFromMenuException:
                return

            profile_id = self.__profile_controller.create_blank_profile()

            if profile_id:
                user = User(username, password, profile_id)
                self.__user_controller.create_user(user)
                print(
                    '\nCongrats! Your account was created. You can add/edit your accont\'s personal info in main menu in \'My profile\',\nwhich you can access after logging in.'
                )
                input('Press any key to continue to back the start page\n')
                return
            else:
                print(
                    '\n>>> An error occured while working with database; try registrating again <<<'
                )
예제 #4
0
    def show(self):
        input_func = get_option_input()

        def get_input():
            selected_option = input_func('Enter option: ')
            if selected_option not in self.next_menus.keys():
                raise UserInputOptionException
            return selected_option

        while True:
            print(self.header)
            print(self.options)

            selected_option = self.input_secure_wrap(get_input)

            next_menu = self.next_menus[selected_option]()
            next_menu.show()
예제 #5
0
    def show(self):
        input_func = get_option_input()

        def get_input():
            selected_option = input_func('Enter option: ')
            if selected_option not in self.__next_menus.keys():
                raise UserInputOptionException
            return selected_option

        while True:
            print(self.__header)
            print(self.__options)

            selected_option = self.input_secure_wrap(get_input)

            next_menu = self.__next_menus[selected_option](
                self.__user_controller, self.__profile_controller,
                self.__post_controller)
            next_menu.show()
예제 #6
0
    def show(self):
        storage = Storage()
        input_func = get_option_input()

        def get_input():
            selected_option = input_func('Enter option: ')
            if selected_option not in self.next_menus.keys():
                raise UserInputOptionException
            return selected_option

        while True:
            print(self.header)
            self.list_questions(storage)
            print(self.options)

            selected_option = self.input_secure_wrap(get_input)

            try:
                self.next_menus[selected_option](storage)
            except ExitFromMenuException:
                return
    def show(self):
        print(self.header)
        
        storage = Storage()
        input_func = get_option_input()
            
        def get_input():
            selected_option = input_func('Enter option: ')
            if selected_option not in self.next_menus:
                raise UserInputOptionException
            return selected_option
        
        while True:
            print('Starting test...')
            self.test(storage)

            print(self.options)

            selected_option = self.input_secure_wrap(get_input)

            if selected_option == '2':
                break
예제 #8
0
    def show(self):
        input_func = get_option_input()

        def get_input():
            selected_option = input_func('Enter option: ')
            if selected_option not in self.__next_menus.keys():
                raise UserInputOptionException
            return selected_option

        while True:
            print(self.__header)
            print('You are welcome,', self.__context.user.user_name + '!')
            print(self.__options)
            selected_option = self.input_secure_wrap(get_input)

            next_menu = self.__next_menus[selected_option](
                self.__user_controller, self.__profile_controller,
                self.__post_controller)

            try:
                next_menu.show()
            except ExitFromMenuException:
                continue