示例#1
0
def join_friend_Screen(name):
    print()
    manage = m.Manage()
    print("Select one of the below options:")
    print("(1) Show My Network")
    print("(2) Search Friend")
    print("(3) List of Pending Friends!")
    print("(4) Go Back to Log In Screen")

    choice = input("Your selection: ")

    #check the right value of input from user
    choice = check.check_option(choice, 1, 4)

    if (choice == "1"):
        list_friend_accept = manage.get_list_friend_accept(name)
        if len(list_friend_accept) != 0:
            print("\nThe list of your friends:")
            print(', '.join(list_friend_accept))
        else:
            print("\nYou don't have any friend in Icollege")

        join_friend_Screen(name)
    elif (choice == "2"):
        search_friend_Screen(name)
    elif (choice == "3"):
        list_friend_pending = manage.get_list_friend_pending(
            name)  # list_friend_pending : is the list of username
        if len(list_friend_pending) != 0:
            print("\nThe list of pending friends: ")
            print(', '.join(list_friend_pending))

        else:
            print("\nYou don't have any pending friend")
        join_friend_Screen(name)
    elif (choice == "4"):
        log_in_Screen(name)
示例#2
0
    def test_importantLinks(
            self
    ):  #adds students to test the creation of default setting values
        filename = "settings.csv"
        f = open(filename, "w+")
        f.close()
        manage = ma.Manage()

        filename2 = "student_data.csv"
        f = open(filename2, "w+")
        f.close()
        manage = ma.Manage()
        #########################################

        stud1 = st.Student("TP1", "P@ssword123", "Tracy", "Pham")
        assert manage.add_student(stud1) == stud1.get_user_name()
        lines = list()
        entry = [" ", " ", " ", " ", " "]
        blank = []
        count = 0
        #read current settings and fill 'lines' with info
        with open(filename, 'r') as readFile:
            reader = csv.reader(readFile)
            for row in reader:
                if row != blank:  #or else there will be stupid amount of white space
                    lines.append(row)
                    count = count + 1
                for field in row:
                    if (field == "TP1"):
                        entry = [
                            lines[count - 1][0], lines[count - 1][1],
                            lines[count - 1][2], lines[count - 1][3],
                            lines[count - 1][4]
                        ]
                        lines.pop()
                        count = count - 1

        assert (stud1.get_user_name() == entry[0])
        assert ("on" == entry[1])
        assert ("on" == entry[2])
        assert ("on" == entry[3])
        assert ("English" == entry[4])

        ##########################################

        stud2 = st.Student("TP2", "P@ssword123", "Thinh", "Phung")
        assert manage.add_student(stud2) == stud2.get_user_name()
        lines = list()
        entry = [" ", " ", " ", " ", " "]
        blank = []
        count = 0
        #read current settings and fill 'lines' with info
        with open(filename, 'r') as readFile:
            reader = csv.reader(readFile)
            for row in reader:
                if row != blank:  #or else there will be stupid amount of white space
                    lines.append(row)
                    count = count + 1
                for field in row:
                    if (field == "TP2"):
                        entry = [
                            lines[count - 1][0], lines[count - 1][1],
                            lines[count - 1][2], lines[count - 1][3],
                            lines[count - 1][4]
                        ]
                        lines.pop()
                        count = count - 1

        assert (stud2.get_user_name() == entry[0])
        assert ("on" == entry[1])
        assert ("on" == entry[2])
        assert ("on" == entry[3])
        assert ("English" == entry[4])

        ##########################################

        stud3 = st.Student("DP", "P@ssword123", "Daniel", "Polt")
        assert manage.add_student(stud3) == stud3.get_user_name()
        lines = list()
        entry = [" ", " ", " ", " ", " "]
        blank = []
        count = 0
        #read current settings and fill 'lines' with info
        with open(filename, 'r') as readFile:
            reader = csv.reader(readFile)
            for row in reader:
                if row != blank:  #or else there will be stupid amount of white space
                    lines.append(row)
                    count = count + 1
                for field in row:
                    if (field == "DP"):
                        entry = [
                            lines[count - 1][0], lines[count - 1][1],
                            lines[count - 1][2], lines[count - 1][3],
                            lines[count - 1][4]
                        ]
                        lines.pop()
                        count = count - 1

        assert (stud3.get_user_name() == entry[0])
        assert ("on" == entry[1])
        assert ("on" == entry[2])
        assert ("on" == entry[3])
        assert ("English" == entry[4])

        ##########################################

        stud4 = st.Student("KP", "P@ssword123", "Kelvin", "Pun")
        assert manage.add_student(stud4) == stud4.get_user_name()
        lines = list()
        entry = [" ", " ", " ", " ", " "]
        blank = []
        count = 0
        #read current settings and fill 'lines' with info
        with open(filename, 'r') as readFile:
            reader = csv.reader(readFile)
            for row in reader:
                if row != blank:  #or else there will be stupid amount of white space
                    lines.append(row)
                    count = count + 1
                for field in row:
                    if (field == "KP"):
                        entry = [
                            lines[count - 1][0], lines[count - 1][1],
                            lines[count - 1][2], lines[count - 1][3],
                            lines[count - 1][4]
                        ]
                        lines.pop()
                        count = count - 1

        assert (stud4.get_user_name() == entry[0])
        assert ("on" == entry[1])
        assert ("on" == entry[2])
        assert ("on" == entry[3])
        assert ("English" == entry[4])

        ##########################################

        stud5 = st.Student("YQ", "P@ssword123", "Yakira", "Quemba")
        assert manage.add_student(stud5) == stud5.get_user_name()
        lines = list()
        entry = [" ", " ", " ", " ", " "]
        blank = []
        count = 0
        #read current settings and fill 'lines' with info
        with open(filename, 'r') as readFile:
            reader = csv.reader(readFile)
            for row in reader:
                if row != blank:  #or else there will be stupid amount of white space
                    lines.append(row)
                    count = count + 1
                for field in row:
                    if (field == "YQ"):
                        entry = [
                            lines[count - 1][0], lines[count - 1][1],
                            lines[count - 1][2], lines[count - 1][3],
                            lines[count - 1][4]
                        ]
                        lines.pop()
                        count = count - 1

        assert (stud5.get_user_name() == entry[0])
        assert ("on" == entry[1])
        assert ("on" == entry[2])
        assert ("on" == entry[3])
        assert ("English" == entry[4])
import pytest
import main
import check as ch
import console as cs
import manage as ma
import string
import csv

#search functionality
manage = ma.Manage()
FILENAME_STD = "student_data.csv"
FILENAME_JOB = "job_data.csv"
FILENAME_STG = "settings.csv"
FILENAME_POL = "policy.csv"
FILENAME_PRO = "profiles.csv"
FILENAME_FRI = "friends.csv"
FILENAME_REQ = "requests.csv"
FILENAME_APP = "applications.csv"
FILENAME_MES = "pending_messages.csv"
FILE_SAVE_MES = "messages.csv"
STORY = "success_story.txt"
empty_string = " "


def test_add__pending_message():
    user1 = "DP"
    user2 = "TP1"
    message = "Pending Message, Test"
    checker = 0
    blank = []
    manage = ma.Manage()
示例#4
0
import manage

if __name__ == "__main__":
    manage.Manage()
示例#5
0
def main():
    try:
        s = manage.Manage()
        s.run()
    except:
        main()
示例#6
0
def job_Screen(name):
    selection = 0
    while (selection != "5"):
        print("Enter '1' to search all jobs in the system")
        print("Enter '2' to view jobs that you have applied for")
        print("Enter '3' to view jobs that you have not applied for")
        print("Enter '4' to view saved jobs.")
        print("Enter '5' to go back.")
        selection = input("Your selection: ")
        #check that acceptable input was provided by the user
        selection = check.check_option(selection, 1, 5)
        if (selection == "1"):  #search all jobs
            manage = m.Manage()
            jobs = list()
            print("The following jobs are currently in the system:")
            with open(FILENAME_JOB, "r") as file:
                reader_csv = csv.reader(file)
                i = 0
                for row in reader_csv:
                    if row != [] and row != [
                            "Title", "Description", "Employer", "Location",
                            "Salary", "Post_Name"
                    ]:
                        i = i + 1
                        jobs.append(row)
                        applied = 0
                        with open(FILENAME_APP, "r") as file:
                            reader_csv_B = csv.reader(file)
                            for entry in reader_csv_B:
                                if entry != []:
                                    if (entry[0] == name) and (entry[1]
                                                               == row[0]) and (
                                                                   entry[2]
                                                                   == row[2]):
                                        applied = applied + 1
                        if applied > 0:
                            print(str(i) + ": " + row[0] + " (Applied)")
                        else:
                            print(str(i) + ": " + row[0])
                job_num = len(jobs)
            choice = job_num + 1
            choice_B = 0
            while (choice != "0"):
                print(
                    "Enter the number of the job you would like to view (and if you wish, save or apply to), or enter '0' to go back"
                )
                choice = input("Your selection: ")
                #check that acceptable input was provided by the user
                choice = check.check_option(choice, 0, job_num)

                if (choice != "0"):
                    print(jobs[int(choice) - 1][0])
                    print("Employer: " + jobs[int(choice) - 1][2])
                    print("Location: " + jobs[int(choice) - 1][3])
                    print("Salary: " + jobs[int(choice) - 1][4])
                    print("Description: " + jobs[int(choice) - 1][1])
                    print()
                    print(
                        "Enter '1' to apply for this job, '2' to save it, or '3' to go back"
                    )
                    choice_B = input("Your selection: ")
                    choice_B = check.check_option(choice_B, 1, 3)
                    if (choice_B == "1"):  #Application
                        applied = 0
                        with open(FILENAME_APP, "r") as file:
                            reader_csv_C = csv.reader(file)
                            for entry in reader_csv_C:
                                if entry != []:
                                    if (entry[0] == name) and (
                                            entry[1]
                                            == jobs[int(choice) - 1][0]) and (
                                                entry[2]
                                                == jobs[int(choice) - 1][2]):
                                        applied = applied + 1
                        if applied > 0:
                            print("You have already applied to that job")
                        else:
                            manage.add_application(name,
                                                   jobs[int(choice) - 1][0],
                                                   jobs[int(choice) - 1][2])
                    elif (choice_B == "2"):  #Save
                        manage.add_save_job(name, jobs[int(choice) - 1][0])
        elif (selection == "2"):  #view jobs applied to
            print("You have applied to the following jobs:")
            with open(FILENAME_APP, "r") as file:
                reader_csv = csv.reader(file)
                i = 0
                for row in reader_csv:
                    if row != [] and row[0] == name:
                        print(row[1] + " at " + row[2])

        ######################################### begin - Thinh ####################################
        elif (selection == "3"):  #view jobs not applied to
            list_application = []  #keep title of applications of the user
            with open(FILENAME_APP, "r") as file:
                reader_csv = csv.reader(file)
                for row in reader_csv:
                    if row != [] and row[0] == name:
                        list_application.append(row[1])

            list_job = []  # keep title of job in the system.
            with open(FILENAME_JOB, "r") as file:
                reader_csv = csv.reader(file)
                for row in reader_csv:
                    if row != [] and row != [
                            "Title", "Description", "Employer", "Location",
                            "Salary", "Post_Name"
                    ]:
                        list_job.append(row[0])

            count = 0
            for element in list_job:
                if element not in list_application:
                    count += 1
                    print(str(count) + ": " + element)

        elif (selection == "4"):  #view saved jobs
            manage = m.Manage()
            list_save_job = manage.list_save_job(name)
            if len(list_save_job) != 0:
                count = 0
                for element in list_save_job:
                    count += 1
                    print(str(count) + ": " + element)
            else:
                print("You don't have any saved job")

            if len(list_save_job) != 0:

                print("Do you want to unmark a job in saved jobs?")
                print("Select one of the below option:")
                print("(1) Unmark")
                print("(2) Keep saved jobs")
                choice = input("Your selection: ")
                #check the right value of input from user
                choice = check.check_option(choice, 1, 2)

                if (choice == "1"):
                    for element in list_save_job:
                        print()
                        print(
                            "Do you want to unmark the job that has the title "
                            + "\"" + element + "\"")
                        print("Select one of the below option:")
                        print("(1) Yes")
                        print("(2) No")
                        choice = input("Your selection: ")
                        #check the right value of input from user
                        choice = check.check_option(choice, 1, 2)
                        if (choice == "1"):
                            manage.delete_save_job(name, element)
                        else:
                            pass

                elif (choice == "2"):
                    pass
        ############################### end -Thinh ###################################
        elif (selection == "5"):  #return
            log_in_Screen(name)
示例#7
0
def check_requests(sign_name):
    manage = m.Manage()
    blank = []
    count = 0
    count2 = 0
    countReq = 0
    addUser1 = list()
    addUser2 = list()
    superLines = list()
    lines = list()
    lines2 = list()

    with open(FILENAME_REQ, 'r') as readFile:
        reader2 = csv.reader(readFile)
        for row2 in reader2:
            if row2 != blank:
                lines2.append(row2)
                count2 = count2 + 1
                if lines2[count2 - 1][1] == sign_name:
                    countReq = countReq + 1

    if countReq > 0:

        print(
            "You have one or more pending friend requests. Do you wish to review them?"
        )
        print("Enter '1' if yes and '0' if no")
        choice = input("Your selection: ")
        # check that user provided acceptable input
        choice = check.check_option(choice, 0, 1)
        if choice == "1":
            with open(FILENAME_REQ, 'r') as readFile:
                reader = csv.reader(readFile)
                for row in reader:
                    if row != blank:
                        if (row[1] != sign_name):
                            superLines.append(row)

            with open(FILENAME_REQ, 'r') as readFile:
                reader = csv.reader(readFile)
                for row in reader:
                    if row != blank:
                        lines.append(row)
                        count = count + 1
                        if lines[count - 1][1] == sign_name:
                            print()
                            print("You have a pending friend request from " +
                                  lines[count - 1][0])
                            print(
                                "Do you accept it? Enter '1' for yes and '0' for no"
                            )
                            accept = input("Your selection: ")
                            accept = check.check_option(accept, 0, 1)
                            if accept == "1":
                                addUser1.append(sign_name)
                                addUser2.append(lines[count - 1][0])

            i = 0
            while i < len(addUser1):
                manage.add_friend(addUser1[i], addUser2[i])
                i = i + 1

            with open(FILENAME_REQ, "w") as writeFile:
                writer = csv.writer(writeFile)
                for line in superLines:
                    writer.writerow(line)
示例#8
0
def log_in_Screen(name):

    check_requests(name)
    check_application(name)

    print()
    print("Select one of the below options:")
    print("(1) Post Job")
    print("(2) Delete Job")
    print("(3) Search Jobs")
    print("(4) Create Profile")
    print("(5) View Profile")
    print("(6) Search for friends to connect with")
    print("(7) Show my network")
    print("(8) New Skill")
    print("(9) Useful links")
    print("(10) Important links")
    print("(11) Sign Out")
    choice = input("Your selection: ")

    #check the right value of input from user
    choice = check.check_option(choice, 1, 11)

    if (choice == "1"):
        manage = m.Manage()
        manage.new_job(name)
        log_in_Screen(name)
    elif (choice == "2"):
        manage = m.Manage()
        list_title_job = []  # keep the titles of jobs that the user posted
        for element in manage.get_list_job():
            if element.get_post_name() == name:
                list_title_job.append(element.get_title())

        if len(list_title_job) != 0:
            print("\nThis is the list of jobs that you posted: ")
            count = 0
            for element in list_title_job:
                count += 1
                print(str(count) + ": " + element)

            for element in list_title_job:
                print()
                print("Do you want to delete the job with title: " + "\"" +
                      element + "\"")
                print("Select one of the below option:")
                print("(1) Yes")
                print("(2) No")
                choice = input("Your selection: ")
                #check the right value of input from user
                choice = check.check_option(choice, 1, 2)
                if choice == "1":
                    manage.delete_job(name, element)
                else:
                    pass
        else:
            print("You didn't post any job in the system!")
        log_in_Screen(name)
    elif (choice == "3"):
        job_Screen(name)
    elif (choice == "4"):
        manage = m.Manage()
        manage.createProfile(name)
        choice = input("\nEnter 1 to return to previous screen: ")
        #check that input has an acceptable value
        choice = check.check_option(choice, 1, 1)
        log_in_Screen(name)
    elif (choice == "5"):
        manage = m.Manage()
        manage.viewProfile(name)
        choice = input("\nEnter 1 to return to previous screen: ")
        #check that input has an acceptable value
        choice = check.check_option(choice, 1, 1)
        log_in_Screen(name)
    elif (choice == "6"):
        student_Search_Console(name)
        log_in_Screen(name)
    elif (choice == "7"):
        show_Network(name)
    elif (choice == "8"):
        learnSkill_Screen(name)
    elif (choice == "9"):
        usefulLinks_Screen(1, name)
    elif (choice == "10"):
        importantLinks_Screen(1, name)
    elif (choice == "11"):
        welcomeScreen()
示例#9
0
def search_friend_Screen(name):
    print()
    print("Select one of the below options:")
    print("(1) Search by Last Name")
    print("(2) Search by University")
    print("(3) Search by Major!")
    print("(4) Go Back to Join Friend Screen")

    choice = input("Your selection: ")

    #check the right value of input from user
    choice = check.check_option(choice, 1, 4)

    if (choice == "1"):
        print()
        search_name = input("Enter your friend's last name: ")
        list_search_name = []  #keep usernames that have the same last name
        manage = m.Manage()
        for element in manage.get_list():
            if element.get_last(
            ) == search_name and element.get_user_name() != name:
                list_search_name.append(element.get_user_name())
        if len(list_search_name) != 0:
            print()
            print("This is the list of people that have the last name: " +
                  search_name)
            print()
            print(', '.join(list_search_name))

            print("Select one of the below options:")
            print("(1) Request to connect to above friends")
            print("(2) Go Back to Join Friend Screen")

            choice = input("Your selection: ")

            #check the right value of input from user
            choice = check.check_option(choice, 1, 2)

            if (choice == "1"):
                list_friend_name = manage.get_list_friend_pending(name)
                list_friend_name_accept = manage.get_list_friend_accept(name)
                print()

                while True:
                    print()
                    friend_name = input(
                        "Enter person's username is listed above you want to request to connect: "
                    )
                    if friend_name in list_search_name and friend_name not in list_friend_name and friend_name not in list_friend_name_accept:  # if the username is in the above list and not in request_friends.csv
                        manage.add_friend(name, friend_name)
                        print()
                        print("Request successfully!\n")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add one more friend")
                        print("(2) Go Back to Join Friend Screen")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            print(', '.join(list_search_name))
                        elif (choice_add == "2"):
                            break
                    elif friend_name in list_search_name and friend_name not in list_friend_name_accept:
                        print()
                        print(
                            "This person is existing on your pending friends")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add another friend")
                        print("(2) Go Back to Join Friend Screen")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            manage.display_information_list_friend(
                                name, list_search_student)
                        elif (choice_add == "2"):
                            break
                    elif friend_name in list_friend_name_accept:
                        print()
                        print("This person was your friend")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add another friend")
                        print("(2) Go Back to Join Friend Screen")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            print()
                            print(', '.join(list_search_name))
                        elif (choice_add == "2"):
                            break

                    else:
                        print()
                        print("The username is not listed above")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add a friend is listed above")
                        print("(2) Go Back to Join Friend Scree")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            #manage.display_information_list_friend(name,list_search_student)
                            print()
                            print(', '.join(list_search_name))
                        elif (choice_add == "2"):
                            break

                search_friend_Screen(name)

            elif (choice == "2"):
                search_friend_Screen(name)

        else:
            print("Do not have any people that have last name: " + search_name)
            search_friend_Screen(name)

    elif (choice == "2"):
        print()
        search_university = input("Enter your friend's university name: ")
        print(search_university.lower())
        list_search_university = [
        ]  #keep usernames that have the same university
        manage = m.Manage()
        for element in manage.get_list_profile():
            if element.get_university().lower() == search_university.lower(
            ) and element.get_user() != name:
                #list_search_student.append(element)
                list_search_university.append(element.get_user())
        if len(list_search_university) != 0:
            print()
            print(
                "This is the list of people that have the university name: " +
                search_university.lower())
            print()
            print(', '.join(list_search_university))
            print()

            print("Select one of the below options:")
            print("(1) Request to connect to above friends")
            print("(2) Go Back to Join Friend Screen")

            choice = input("Your selection: ")

            #check the right value of input from user
            choice = check.check_option(choice, 1, 2)

            if (choice == "1"):
                list_friend_name = manage.get_list_friend_pending(name)
                list_friend_name_accept = manage.get_list_friend_accept(name)
                print()

                while True:
                    print()
                    friend_name = input(
                        "Enter person's username is listed above you want to request to connect: "
                    )
                    if friend_name in list_search_university and friend_name not in list_friend_name and friend_name not in list_friend_name_accept:  # if the username is in the above list and not in request_friends.csv
                        manage.add_friend(name, friend_name)
                        print()
                        print("Request successfully!\n")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add one more friend")
                        print("(2) Go Back to Join Friend Screen")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            print(', '.join(list_search_university))
                        elif (choice_add == "2"):
                            break
                    elif friend_name in list_search_university and friend_name not in list_friend_name_accept:
                        print()
                        print(
                            "This person is existing on your pending friends")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add another friend")
                        print("(2) Go Back to Join Friend Screen")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            print()
                            print(', '.join(list_search_university))
                        elif (choice_add == "2"):
                            break
                    elif friend_name in list_friend_name_accept:
                        print()
                        print("This person was your friend")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add another friend")
                        print("(2) Go Back to Join Friend Screen")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            print()
                            print(', '.join(list_search_university))
                        elif (choice_add == "2"):
                            break

                    else:
                        print()
                        print("The username is not listed above")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add a friend is listed above")
                        print("(2) Go Back to Join Friend Scree")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            print()
                            print(', '.join(list_search_university))

                        elif (choice_add == "2"):
                            break

                search_friend_Screen(name)

            elif (choice == "2"):
                search_friend_Screen(name)

        else:
            print("Do not have any people that have university name: " +
                  search_university.lower())
            search_friend_Screen(name)
    elif (choice == "3"):
        print()
        search_major = input("Enter your friend's major name: ")
        print(search_major.lower())
        list_search_major = []  #keep usernames that have the same major
        manage = m.Manage()
        for element in manage.get_list_profile():
            if element.get_major().lower() == search_major.lower(
            ) and element.get_user() != name:
                #list_search_student.append(element)
                list_search_major.append(element.get_user())
        if len(list_search_major) != 0:
            print()
            print("This is the list of people that have the major name: " +
                  search_major.lower())
            print()
            print(', '.join(list_search_major))
            print()

            print("Select one of the below options:")
            print("(1) Request to connect to above friends")
            print("(2) Go Back to Join Friend Screen")

            choice = input("Your selection: ")

            #check the right value of input from user
            choice = check.check_option(choice, 1, 2)

            if (choice == "1"):
                list_friend_name = manage.get_list_friend_pending(name)
                list_friend_name_accept = manage.get_list_friend_accept(name)
                print()

                while True:
                    print()
                    friend_name = input(
                        "Enter person's username is listed above you want to request to connect: "
                    )
                    if friend_name in list_search_major and friend_name not in list_friend_name and friend_name not in list_friend_name_accept:  # if the username is in the above list and not in request_friends.csv
                        manage.add_friend(name, friend_name)
                        print()
                        print("Request successfully!\n")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add one more friend")
                        print("(2) Go Back to Join Friend Screen")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            print(', '.join(list_search_major))
                        elif (choice_add == "2"):
                            break
                    elif friend_name in list_search_major and friend_name not in list_friend_name_accept:
                        print()
                        print(
                            "This person is existing on your pending friends")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add another friend")
                        print("(2) Go Back to Join Friend Screen")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            print()
                            print(', '.join(list_search_major))
                        elif (choice_add == "2"):
                            break
                    elif friend_name in list_friend_name_accept:
                        print()
                        print("This person was your friend")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add another friend")
                        print("(2) Go Back to Join Friend Screen")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            print()
                            print(', '.join(list_search_major))
                        elif (choice_add == "2"):
                            break

                    else:
                        print()
                        print("The username is not listed above")
                        print()
                        print("Select one of the below options:")
                        print("(1) Add a friend is listed above")
                        print("(2) Go Back to Join Friend Scree")

                        choice_add = input("Your selection: ")
                        #check the right value of input from user
                        choice_add = check.check_option(choice_add, 1, 2)
                        if (choice_add == "1"):
                            print()
                            print(', '.join(list_search_major))

                        elif (choice_add == "2"):
                            break

                search_friend_Screen(name)

            elif (choice == "2"):
                search_friend_Screen(name)

        else:
            print("Do not have any people that have major name: " +
                  search_major.lower())
            search_friend_Screen(name)
    elif (choice == "4"):
        join_friend_Screen(name)
示例#10
0
def log_in_Screen(name):
    print()
    manage = m.Manage()
    list_request = []  # list of usernames request for this user

    for element in manage.get_list_pending_friend():
        if element.get_pending_name() == name:
            list_request.append(element.get_request_name())
    if len(list_request) != 0:
        print("You have some requests from some friends")
        print("This is the list of friends that requested to you:")
        print()
        for element in list_request:
            print(element)

        print()

        for element in list_request:  # element keeps usernam of request
            print()
            print("Do you want to accept or reject from " + element + " ?")
            print("Select one of the below options:")
            print("(1) Accept")
            print("(2) Reject")

            choice = input("Your selection: ")
            #check the right value of input from user
            choice = check.check_option(choice, 1, 2)

            if (choice == "1"):
                manage.add_accept_friend(element, name)
                manage.delete_add_friend(name, element)
            elif (choice == "2"):
                manage.delete_add_friend(name, element)

    print()
    print("Select one of the below options:")
    print("(1) Post Job")
    print("(2) Search Job")
    print("(3) Join Friend")
    print("(4) Create Profile")
    print("(5) View Profile")
    print("(6) Display friends profile")
    print("(7) New Skill")
    print("(8) Useful links")
    print("(9) Important links")
    print("(10) Sign Out")
    choice = input("Your selection: ")

    #check the right value of input from user
    choice = check.check_option(choice, 1, 10)

    if (choice == "1"):
        manage.new_job(name)
        log_in_Screen(name)
    elif (choice == "2"):
        print("\nUnder Construction")
        log_in_Screen(name)
    elif (choice == "3"):
        join_friend_Screen(name)
    elif (choice == "4"):
        manage.createProfile(name)
        choice = input("\nEnter 1 to return to previous screen: ")
        #check the right value of input from user
        choice = check.check_option(choice, 1, 1)
        log_in_Screen(name)
    elif (choice == "5"):
        manage.viewProfile(name)
        choice = input("\nEnter 1 to return to previous screen: ")
        #check the right value of input from user
        choice = check.check_option(choice, 1, 1)
        log_in_Screen(name)
    elif (choice == "6"):
        list_friend_accept = manage.get_list_friend_accept(name)
        if len(list_friend_accept) != 0:
            print("\nThis is the list of your friends")

            while True:
                print(', '.join(list_friend_accept))
                username_friend = input(
                    "Enter your friend's username to see his/her profile: ")
                if username_friend in list_friend_accept:
                    manage.viewProfile(username_friend)
                    print()
                    print("Select one of the below options:")
                    print("(1) See another profile")
                    print("(2) Come Back to Log In Screen")
                    choice = input("Your selection: ")

                    #check the right value of input from user
                    choice = check.check_option(choice, 1, 2)
                    if (choice == "1"):
                        continue
                    elif (choice == "2"):
                        break
                else:
                    print("\nHe/she is not your friends")
                    print()
                    print("Select one of the below options:")
                    print("(1) Try again")
                    print("(2) Come Back to Log In Screen")
                    choice = input("Your selection: ")

                    #check the right value of input from user
                    choice = check.check_option(choice, 1, 2)

                    if (choice == "1"):
                        continue
                    elif (choice == "2"):
                        break
            log_in_Screen(name)

        else:
            print("\nYou don't have any friend in Icollege")
            log_in_Screen(name)
    elif (choice == "7"):
        learnSkill_Screen(name)
    elif (choice == "8"):
        usefulLinks_Screen(1, name)
    elif (choice == "9"):
        importantLinks_Screen(1, name)
    elif (choice == "10"):
        welcomeScreen()