Beispiel #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
 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)
    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_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)
    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
 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))
    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)
Beispiel #8
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
Beispiel #9
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!'))
    def display_groups(group_list, exit_with_enter=False):
        """
        Displays groups

        :param group_list:list -> list of current groups
        :param exit_with_enter:bool -> decides if methode should wait for input at the end
        :return: None
        """
        os.system('clear')
        print(ColorfulView.format_string_to_yellow('Current groups: '))
        for group in group_list:
            print(str(group_list.index(group)) + '. ' + group.name)
        if exit_with_enter:
            input('Press enter to return')
Beispiel #11
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()
 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())
    def add_user_name():
        """
        Param: None
        Return: str

        Method create users name and return it.
        """
        incorrect = True
        user_name = ''
        while incorrect:

            print(
                ColorfulView.format_string_to_yellow(
                    'Enter your name and surname: '))
            user_name = input()

            if re.match(r'^(?=[A-Za-z])[\sA-Za-z]{5,30}$', user_name):
                incorrect = False

        return user_name
    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)
    def create_user_password():
        """
        Arguments: none
        Return: none

        Method let to create user his account password and check if it contain requirements.
        """
        incorrect_password = True
        user_password = ''
        while incorrect_password:
            print(
                ColorfulView.format_string_to_yellow(
                    'Enter your password(it must contain big, small characters and '
                    'digit, it must contain min 6 chars and '
                    'it cant be longer than 30 characters): '))
            user_password = PasswordService.get_password_with_asterisks()
            if re.match(r'^(?=.*?\d)(?=.*?[A-Z])(?=.*?[a-z])[A-Za-z\d]{6,30}$',
                        user_password):
                incorrect_password = False

        return user_password
Beispiel #16
0
    def print_table(users):
        """
        Method display formated table from object of UserContainer class.

        Param: list --> UserContainer Class
        Return: None
        """
        t = Texttable()
        t.set_cols_dtype(['a', 'a', 'a', 'a', 'i', 'a'])

        tittles = ['Index', 'Login', 'Name', 'Group', 'Phone Number', 'E-mail']
        tittles = [ColorfulView.format_string_to_green(i) for i in tittles]

        t.add_rows([tittles] + [[
            i + STARTING_INDEX,
            ColorfulView.format_string_to_yellow(u.get_login()),
            u.get_name(), 'Not assigned' if not u.group else u.group,
            u.get_phone_number(),
            u.get_email()
        ] for i, u in enumerate(users)])

        print(t.draw())
    def create_user_phone_number():
        """
        Param: none
        Return: str

        Method check if user phone number is digits, and its lenght is 9.
        """
        os.system('clear')
        incorrect_phone_number = True
        phone_number = ''
        while incorrect_phone_number:
            print(
                ColorfulView.format_string_to_yellow(
                    'Enter your phone number: '))
            phone_number = input()

            if re.match(r'\d{3}[\s\\\/\-]?\d{3}[\s\\\/\-]?\d{3}',
                        phone_number):
                incorrect_phone_number = False

        phone_number = RootView.convert_phone_number_to_data_format(
            phone_number)
        return phone_number
    def create_user_login():
        """
        Param: none
        Return: str

        Method check if user login is entered correctly with requirements.
        """
        max_login_lenght = 30
        min_login_lenght = 5

        incorrect_input = True
        user_login = ''
        while incorrect_input:
            print(
                ColorfulView.format_string_to_yellow(
                    'Enter your login(it must contain 6 '
                    'characters and cant be longer than 30 characters): '))
            user_login = input()

            if len(user_login) > min_login_lenght and len(
                    user_login) < max_login_lenght:
                incorrect_input = False

        return user_login
 def print_user_have_no_grades():
     os.system('clear')
     print(
         ColorfulView.format_string_to_yellow('You have no added grades !'))
     input('\nPress ENTER to continue')