Exemplo n.º 1
0
def create_application(filename, filename_2, filename_3):
    table = file_handling.import_data(filename)  #import position table
    table_2 = file_handling.import_data(filename_2)  #import company table
    table_3 = file_handling.import_data(filename_3)  #import company table
    students_list = []
    for record in table_2:
        students_list.append(record[0])
    positions_list = []
    for record in table_3:
        positions_list.append(record[0])
    data = ui.user_input("Please give me the position's data",
                         ["Accepted: "])  # user input
    while True:
        temp_student_id = ui.user_input("", ["Student ID: "])
        if temp_student_id[0] in students_list:
            break
        ui.print_message("Wrong Student ID")
    while True:
        temp_position_id = ui.user_input("", ["Postition ID: "])
        if temp_position_id[0] in positions_list:
            break
        ui.print_message("Wrong Position_ID")
    data.append(temp_student_id[0])
    data.append(temp_position_id[0])
    id = misc.generate_random(table)  # generate id
    new_table = misc.append_table(table,
                                  misc.build_record(id,
                                                    data))  # making new table
    file_handling.export_data(new_table, filename, "w")  # saving the new table
Exemplo n.º 2
0
def update_student(filename):
    table = file_handling.import_data(filename)  #import table
    id = ui.user_input("Please give me the student's ID",
                       ["ID: "])  # user input, ID
    data = ui.user_input(
        "Please give me the student's data",
        ["Name: ", "Age: ", "Active?: "])  # user input, rest info
    new_table = misc.update_table(table, id[0], misc.build_record(
        id[0], data))  # updating the table
    file_handling.export_data(new_table, filename, "w")  # saving the new table
Exemplo n.º 3
0
def state_student(filename):
    table = file_handling.import_data(filename)  #import table
    id = ui.user_input("Please give me the student's ID",
                       ["ID: "])  # user input, ID
    data = ui.user_input("Please give me the student's data",
                         ["Active?: "])  # user input, Active?
    new_table = []
    for record in table:
        if record[0] != id[0]:
            new_table.append(record)
        else:
            record[3] = data[0]
            new_table.append(record)
    file_handling.export_data(new_table, filename, "w")  # saving the new table
Exemplo n.º 4
0
def update_application(filename):
    table = file_handling.import_data(filename)  #import table
    id = ui.user_input("Please give me the application's ID",
                       ["ID: "])  # user input, ID
    data = ui.user_input("Please give me the application's data",
                         ["Accepted: "])  # user input, Active?
    new_table = []
    for record in table:
        if record[0] != id[0]:
            new_table.append(record)
        else:
            record[1] = data[0]
            new_table.append(record)
    file_handling.export_data(new_table, filename, "w")  # saving the new table
Exemplo n.º 5
0
def create_student(filename):
    table = file_handling.import_data(filename)  #import table
    data = ui.user_input("Please give me the student's data",
                         ["Name: ", "Age: ", "Active?: "])  # user input
    id = misc.generate_random(table)  # generate id
    new_table = misc.append_table(table,
                                  misc.build_record(id,
                                                    data))  # making new table
    file_handling.export_data(new_table, filename, "w")  # saving the new table
Exemplo n.º 6
0
def delete_company(filename, pos_table):
    table = file_handling.import_data(filename) #import table
    pos_table = file_handling.import_data(pos_file) # import positions table
    id = ui.user_input("Please give me the ID of the company", ["ID: "]) # user input, ID
    for index in range(len(table)): # deleting an element from the table by index
        if table[index][0] == id[0]:
            del table[index]
            break
    file_handling.export_data(table, filename, "w")
Exemplo n.º 7
0
def delete_application(filename):
    table = file_handling.import_data(filename)  #import table
    id = ui.user_input("Please give me the application's ID",
                       ["ID: "])  # user input, ID
    for index in range(
            len(table)):  # deleting an element from the table by index
        if table[index][0] != id[0]:
            del table[index]
            break
    file_handling.export_data(table, filename, "w")
Exemplo n.º 8
0
def read_position(filename):
    table = file_handling.import_data(filename)  # import table
    id = ui.user_input("Please give me the position's ID",
                       ["ID: "])  # user input, ID
    titles = ["ID", "Description", "Number of seats", "Company ID"]
    filtered_table = []
    for record in table:
        if record[0] == id[0]:
            filtered_table.append(record)
            ui.print_table(filtered_table, titles)
Exemplo n.º 9
0
def create_position(filename, filename_2):
    table = file_handling.import_data(filename)  #import position table
    table_2 = file_handling.import_data(filename_2)  #import company table
    comp_list = []
    for record in table_2:
        comp_list.append(record[0])
    data = ui.user_input("Please give me the position's data",
                         ["Description: ", "Number of seats: "])  # user input
    while True:
        temp_company_id = ui.user_input("", ["Company ID: "])
        if temp_company_id[0] in comp_list:
            break
        ui.print_message("Wrong ID")
    data.append(temp_company_id[0])
    id = misc.generate_random(table)  # generate id
    new_table = misc.append_table(table,
                                  misc.build_record(id,
                                                    data))  # making new table
    file_handling.export_data(new_table, filename, "w")  # saving the new table
Exemplo n.º 10
0
def read_company(filename, pos_file):
    table = file_handling.import_data(filename) # import table
    pos_table = file_handling.import_data(pos_file) # import positions table
    id = ui.user_input("Please give me the ID of the company",["ID: "]) # user input, ID
    titles = ["ID", "Name"]
    titles_2 = ["Positions ID", "Description", "Seats", "Company ID"]
    filtered_table = []
    pos_filtered_table = []
    for record in table:
        if record[0] == id[0]:
            filtered_table.append(record)
            ui.print_table(filtered_table, titles)
    for record in pos_table:
        if record[3] == filtered_table[0][0]:
            pos_filtered_table.append(record)
    if len(pos_filtered_table) != 0:
        ui.print_table(pos_filtered_table, titles_2)
Exemplo n.º 11
0
def read_student(st_file, app_file):
    st_table = file_handling.import_data(st_file)  # import students table
    app_table = file_handling.import_data(app_file)  # import application table
    id = ui.user_input("Please give me the student's ID",
                       ["ID: "])  # user input, ID
    titles = ["Students ID", "Name", "Age", "Status"]
    titles_2 = ["Application ID", "Accepted", "Student ID", "Position ID"]
    filtered_table = []
    app_filtered_table = []
    for record in st_table:
        if record[0] == id[0]:
            filtered_table.append(record)
            ui.print_table(filtered_table, titles)
    for record in app_table:
        if record[2] == filtered_table[0][0]:
            app_filtered_table.append(record)
    if len(app_filtered_table) != 0:
        ui.print_table(app_filtered_table, titles_2)
Exemplo n.º 12
0
def delete_student(st_file, app_file):
    st_table = file_handling.import_data(st_file)  #import table
    app_table = file_handling.import_data(app_file)  #import table
    app_list = []
    for record in app_table:
        app_list.append(record[2])
    while True:
        id = ui.user_input("Please give me the student's ID",
                           ["ID: "])  # user input, ID
        if id[0] in app_list:
            ui.print_message(
                "This student has an application, You can't delete it!")
        else:
            break
    for index in range(
            len(st_table)):  # deleting an element from the table by index
        if st_table[index][0] == id[0]:
            del st_table[index]
            break
    file_handling.export_data(st_table, st_file, "w")
Exemplo n.º 13
0
def update_company(filename):
    table = file_handling.import_data(filename) #import table
    id = ui.user_input("Please give me the ID of the company", ["ID: "]) # user input, ID
    data = ui.user_input("Please give me the datas of the company", ["Name: "]) # user input, rest info
    new_table = misc.update_table(table, id[0], misc.build_record(id[0], data)) # updating the table
    file_handling.export_data(new_table, filename, "w") # saving the new table