예제 #1
0
    def display_chose_user_to_promote(users):
        """
        Method display users to promote to students.

        Param: list ----> object of user container
        Return: object of User class / None
        """
        os.system('clear')
        index = 1

        for person in users:
            print('\n' + str(index) + '. ' +
                  ColorfulView.format_string_to_green(person.name) +
                  ', Login: '******', Email: ' +
                  ColorfulView.format_string_to_yellow(person.email))
            index += 1

        incorrect = True
        while incorrect:
            user_index = input('Enter user index to promote(or back): ')

            if user_index.isdigit():
                user = EmployeeView.get_user_by_index(user_index, users)
                return user

            elif user_index == 'back':
                incorrect = False
예제 #2
0
    def display_main_menu():
        """
        Param: none
        Return: none

        Method display main menu options.
        """
        welcome_information = '\nWelcome in Canvas, patch 0.-2XYZ.4C version.'
        exit_program = '0. Exit'
        menu_options = ['Sign in', 'Sign up', 'Restore password']
        number_option = 1
        welcome_information = ColorfulView.format_string_to_yellow(
            welcome_information)
        exit_program = ColorfulView.format_string_to_red(exit_program)

        print(welcome_information)

        for option in menu_options:
            option = str(number_option) + '. ' + option
            option = ColorfulView.format_string_to_green(option)
            print(option)
            number_option = int(number_option)
            number_option += 1

        print(exit_program)
 def get_password_with_asterisks():
     """
     Hide password while typing
     :return:
     """
     password = []
     password_created = False
     while not password_created:
         os.system('clear')
         print('*' * (len(password if password else 1) - 1) + password[-1] if password else '')
         print(ColorfulView.format_string_to_yellow('Enter password') + '(press ESC to back):', end='')
         time.sleep(0.1)
         os.system('clear')
         print('*' * len(password))
         print(ColorfulView.format_string_to_yellow('Enter password') + '(press ESC to back):', end='')
         x = getch()
         if x == chr(27):
             raise RuntimeError("User pressed ESC in password creator")
         elif x == '\r':
             print('')
             password_created = True
         elif x == '\x7f':
             if password:
                 del password[-1]
         else:
             password.append(x)
     return ''.join(password)
예제 #4
0
 def display_student_grades(grades_list: dict):
     if not grades_list:
         print(
             ColorfulView.format_string_to_blue(
                 'You have no added grades !'))
     print(ColorfulView.format_string_to_yellow('Assignments with grades:'))
     for key, value in grades_list.items():
         print('Assignment name: {}; Grade: {}'.format(key, value))
예제 #5
0
 def new_assignment_input(is_title=True):
     if is_title:
         input_message = ColorfulView.format_string_to_yellow(
             'Name your assignment: ')
     else:
         input_message = ColorfulView.format_string_to_blue(
             'Describe this assignment: ')
     string = input(input_message)
     return string
예제 #6
0
 def display_error_message(error_msg: str):
     """
     Method displays error message
     :param error_msg: str -> An error message.
     :return: None
     """
     os.system('clear')
     print(ColorfulView.format_string_to_red(error_msg))
     input(ColorfulView.format_string_to_green(CONFIRM_MESSAGE))
예제 #7
0
 def display_password_changed_successfully():
     """
     Method displays that password have been changed successfully.
     :return: None
     """
     os.system('clear')
     print(
         ColorfulView.format_string_to_green(
             'You password have been changed successfully'))
     input(ColorfulView.format_string_to_green(CONFIRM_MESSAGE))
예제 #8
0
    def display_is_email_sent(email):
        """
        Method display infromation about emails is it send.

        Param: str
        Return: None
        """
        email = ColorfulView.format_string_to_yellow(email)
        print(email +
              ColorfulView.format_string_to_green(' - email has been sent!'))
예제 #9
0
    def display_user_grades(assignments: list):
        os.system('clear')
        print(ColorfulView.format_string_to_green('Your grades:'))
        for index, assignment in enumerate(assignments):
            index += INDEX_INCREMENTOR
            print(
                ColorfulView.format_string_to_blue(str(index) + '. ') +
                assignment)

        input('\nPress ENTER to continue')
예제 #10
0
    def get_user_login():
        """
        Param: none
        Return: str

        Method make string of user login using key getch.
        """
        login = []
        login_created = False
        while not login_created:
            os.system('clear')
            print(ColorfulView.format_string_to_yellow('Enter your login') +
                  '(ESC to back to menu):',
                  end='')
            print(''.join(login))

            x = getch()
            if x == chr(27):
                raise RuntimeError("User pressed ESC in password creator")
            elif x == '\r':
                print('')
                login_created = True

            elif x == '\x7f':
                if login:
                    del login[-1]
            else:
                login.append(x)
        return ''.join(login)
예제 #11
0
    def create_user_email():
        """
        Param: none
        Return: str

        Method check if user email is enter correctly with requirements.
        """
        max_email_lenght = 30
        min_email_lenght = 0

        incorrect_email_adress = True
        while incorrect_email_adress:
            print(
                ColorfulView.format_string_to_yellow(
                    'Enter your email adress'
                    '(it cant be longer than 30 characters): '))
            user_email = input()

            if len(user_email) > min_email_lenght and len(
                    user_email) < max_email_lenght:
                if re.match(
                        r'([A-Za-z\d\.]{1,})([\@]{1})([a-z\d]{1,}[\.]{1}[a-z]{2,})',
                        user_email):
                    incorrect_email_adress = False

        return user_email
예제 #12
0
    def display_menu(name_of_user):
        """
        Method display menu of Employee account.

        Param: str ---> object of Employee Class, attribute name
        Return: str
        """
        welcome = ColorfulView.format_string_to_yellow(
            '\tWelcome {}, this is your account options.\n'.format(
                name_of_user))
        title = ColorfulView.format_string_to_blue('\nChoose option:\n')
        options = '\n1. Show students\n2. Promote user to student\n3. Ask for send email about cofee fundarising\n0. Log out'

        print(welcome, title, options)

        return input()
예제 #13
0
 def display_mentor_information(mentor_data):
     """
     Display information about mentor
     :param mentor_data: mentor object
     :return:
     """
     os.system('clear')
     print(
         ColorfulView.format_string_to_yellow('Login: '******'\nName: ') +
         mentor_data.get_name() +
         ColorfulView.format_string_to_green('\nPhone number: ') +
         mentor_data.get_phone_number() +
         ColorfulView.format_string_to_green('\nEmail: ') +
         mentor_data.get_email())
예제 #14
0
 def display_user_already_exist():
     """
     Method display information about user already exist.
     """
     exist_info = ColorfulView.format_string_to_red(
         'This user already exist as stundet!')
     print(exist_info)
예제 #15
0
    def display_date_error():
        """
        Prints out date error

        :return: None
        """
        print(ColorfulView.format_string_to_red('Wrong date format!'))
        input('Press enter to return')
예제 #16
0
 def display_emails_input_error():
     """
     Method display input error message.
     """
     print(
         ColorfulView.format_string_to_red(
             'You type wrong input! Why you dont spam students by emails!'))
     input()
예제 #17
0
 def display_that_token_have_been_sent():
     """
     Method display that token has been sent.
     :return: None
     """
     print(
         ColorfulView.format_string_to_green(
             "You can find the token in your e-mail or SMS box."))
예제 #18
0
    def display_user_assignments(assignments: list):
        os.system('clear')
        print(
            ColorfulView.format_string_to_yellow(
                'Assignments without your submission: '))

        for index, assignment in enumerate(assignments):
            print(str(index) + '. ' + assignment)
예제 #19
0
 def display_empty_list_message():
     """
     Display message about empty list
     :return:
     """
     print('')
     print(ColorfulView.format_string_to_red('List is empty!'))
     input('\nPress ENTER to continue')
예제 #20
0
    def display_index_error():
        """
        Prints out display error

        :return: None
        """
        print(ColorfulView.format_string_to_red('Wrong index!'))
        input('Press enter to return')
예제 #21
0
    def display_error_user_singin():
        """
        Param: none
        Return: none

        Method display infromation when created user try to signing without any status of student, mentor etc.
        """
        os.system('clear')
        print(
            ColorfulView.format_string_to_green(
                '\nYou are trying to sign in as random user,'
                ' please wait for manager or mentor to change your status!'))
        print(
            ColorfulView.format_string_to_white(
                '\n\nWe will inform you when it will be ready.'
                '\n\nThank you for patience!'))
        time.sleep(4)
예제 #22
0
    def show_invalid_input():
        """
        Prints out input error

        :return: None
        """
        print(ColorfulView.format_string_to_red('Invalid input!'))
        input('Press enter to return')
예제 #23
0
 def display_user_not_found():
     """
     Display information that user is not found
     :return:
     """
     print(
         ColorfulView.format_string_to_red(
             'User with that name not found!'))
     input('\nPress ENTER to continue ')
예제 #24
0
 def get_value_to_change():
     """
     Get value to change mentor data
     :return:
     """
     return input(
         'Enter what do you want to change(' +
         ColorfulView.format_string_to_green('login, phone, email, name') +
         '):')
예제 #25
0
 def display_wrong_attribute():
     """
     Display message about wrong attribute typed
     :return:
     """
     print(
         ColorfulView.format_string_to_red(
             'There is no such attribute to change!'))
     input('\nPress ENTER to continue')
예제 #26
0
    def display_not_enough_data():
        """
        Prints out not enough data error message

        :return: None
        """
        print(
            ColorfulView.format_string_to_red(
                'You have no students/groups/assignments added'))
예제 #27
0
 def display_user_deleted(user):
     """
     Display information about deleted user
     :param user: User object
     :return:
     """
     print(
         ColorfulView.format_string_to_red(
             'User: {} has been deleted'.format(user.get_login())))
     input('\nPress ENTER to continue')
예제 #28
0
 def display_user_promoted(user):
     """
     Display information that user has been promoted
     :param user: User object
     :return:
     """
     print(
         ColorfulView.format_string_to_green(
             'User: {} has been promoted'.format(user.get_login())))
     input('\nPress ENTER to continue')
예제 #29
0
    def display_sign_menu(sign_up):
        """
        Param: bool
        Return: none

        Method check if user want to sign in or create new account in platform and display infromation.
        """
        os.system('clear')
        create_new_user_info = '\nAs new user of our platform you need to sign up with your email and unique password!'
        create_new_user_info = ColorfulView.format_string_to_green(
            create_new_user_info)

        sign_in_as_user_info = '\nAs a user of our platform you need to sign in with your login and password.'
        sign_in_as_user_info = ColorfulView.format_string_to_yellow(
            sign_in_as_user_info)

        if sign_up:
            print(create_new_user_info)
        else:
            print(sign_in_as_user_info)
예제 #30
0
    def display_user_not_exist():
        """
        Param: none
        Return: none

        Method display information about not existing user account
        if someone try to singin with not exist login in database.
        """
        os.system('clear')
        print(ColorfulView.format_string_to_red('User not exists!'))
        time.sleep(0.5)