Ejemplo n.º 1
0
def update_position(table, file_name, position_ID):
    updated_desc = input("Enter updated description here: ")

    for i in table:
        if i[0] == position_ID:
            i[1] = updated_desc

    data_manager.export_file(table, file_name, "w")
Ejemplo n.º 2
0
def create_student(file_name):  # Create Student

    student_ID = ui.generate_random()
    student_name = ui.get_input("Enter a student name here: ")
    student_age = ui.get_input("Enter a student age here: ")
    student_active = "Active"
    student = [student_ID, student_name, student_age, student_active]

    data_manager.export_file(student, file_name, "a")
Ejemplo n.º 3
0
def update_application(table, file_name, application_ID):

    updated_status = ui.get_input("Enter updated status here: ")

    for i in table:
        if i[0] == application_ID:
            i[1] = updated_status

    data_manager.export_file(table, file_name, "w")
Ejemplo n.º 4
0
def create_company(table, file_name):
    '''

    Users can create new companies. Companies have an ID, name.
    IDs and names of companies are unique amongst other companies.'''
    company_id = ui.generate_random()
    company_name = ui.get_input("Enter your company name: ")
    company_datas = [company_id, company_name]
    data_manager.export_file(company_datas, file_name, "a")
Ejemplo n.º 5
0
def update_student(table, student_ID, file_name):  # Update Student
    updated_name = ui.get_input("Enter updated name here: ")
    updated_age = ui.get_input("Enter updated age here: ")

    for i in table:
        if i[0] == student_ID:
            i[1] = updated_name
            i[2] = updated_age

    data_manager.export_file(table, file_name, "w")
Ejemplo n.º 6
0
def delete_position(table, file_name):

    position_id_by_user = ui.get_input("Enter position id: ")
    is_in_position = True
    for j in data_manager.import_file("application.csv"):
        if j[3] == position_id_by_user:
            is_in_position = False

    if is_in_position:
        for i in table:
            if i[0] == position_id_by_user:
                table.remove(i)
    data_manager.export_file(table, file_name, "w")
Ejemplo n.º 7
0
def update_company(table, file_name):
    '''

    Users can update the details of existing companies by first entering their ID and then the information (name) to be updated.
    IDs cannot be updated.
    Company names can be updated, but they should stay unique.'''
    company_id_by_user = ui.get_input("Enter company id: ")
    for i in table:
        if i[0] == company_id_by_user:
            new_name = ui.get_input("Enter new company name: ")
            i[1] = new_name
            new_datas = [i]

    data_manager.export_file(table, file_name, "w")
Ejemplo n.º 8
0
def activate_deactivate_student(table, student_ID,
                                file_name):  # Activate/Deactivate Student
    for i in table:
        if i[0] == student_ID:
            change = input("Student's current status is: " + i[3] +
                           "  Would you like to change it? (Y/N) ")
            if change.upper() == "Y" and i[3] == "Active":
                i[3] = "Inactive"
                continue
            if change.upper() == "Y" and i[3] == "Inactive":
                i[3] = "Active"
            else:
                continue

    data_manager.export_file(table, file_name, "w")
Ejemplo n.º 9
0
def create_position(file_name):
    '''

    Users can create new positions. A position has an ID, description, number of seats and a “Company ID”.
    Position IDs are unique amongst other positions.
    Descriptions cannot be empty.
    The number of seats must be greater than 0.
    Company ID must exist.'''

    position_id = ui.generate_random()
    description = ui.get_input("Write position description: ")
    number_of_seat = ui.get_input("Enter the number of seats: ")
    company_id_position = ui.get_input("Enter company id: ")
    for i in data_manager.import_file("company.csv"):
        if i[0] == company_id_position:
            final_id = [ position_id, description, number_of_seat, company_id_position]
            data_manager.export_file(final_id, file_name, "a")
Ejemplo n.º 10
0
def delete_company(table, file_name):
    '''

    Users can delete existing companies by entering their ID.
    Companies cannot be deleted if they have an existing “Position”.'''

    company_id_by_user = ui.get_input("Enter company id: ")
    is_in_position = True
    for j in data_manager.import_file("postion.csv"):
        if j[3] == company_id_by_user:
            is_in_position = False

    if is_in_position:
        for i in table:
            if i[0] == company_id_by_user:
                table.remove(i)
                data_manager.export_file(table, file_name, "w")
Ejemplo n.º 11
0
def create_application(file_name):
    '''

    Users can create new applications. An application has an ID, an “accepted” field, a “Student ID” and a “Position ID”.
    IDs are unique amongst other applications.
    Student and Position IDs must exist.
    The “accepted” field stores whether the application was accepted by a company or not.'''

    application_ID = ui.generate_random()
    student_ID = input("Enter student ID here: ")
    position_ID = input("Enter position ID here: ")
    accepted = "Pending"
    application_data = [application_ID, accepted, student_ID, position_ID]
    for i in data_manager.import_file("student.csv"):
        if i[0] == student_ID:
            for j in data_manager.import_file("postion.csv"):
                if j[0] == position_ID:
                    data_manager.export_file(application_data, file_name, "a")
Ejemplo n.º 12
0
def delete_student(table, student_ID, file_name):  # Delete Students
    for i in table:
        if i[0] == student_ID:
            table.remove(i)

    data_manager.export_file(table, file_name, "w")
Ejemplo n.º 13
0
def delete_application(table, file_name, application_ID):
    for i in table:
        if i[0] == application_ID:
            table.remove(i)

    data_manager.export_file(table, file_name, "w")