def update(positions): position = common.check_id(positions) if position: inputs = ui.get_inputs(["Description: "]) position.description = inputs[0] else: ui.print_notification("No position found with that ID!")
def update(students): student = common.check_id(students) if student: inputs = ui.get_inputs(["Name: ", "Age: "]) (student.name, student.age) = (inputs[0], inputs[1]) else: ui.print_notification("No student found with that ID!")
def read(companies): company = common.check_id(companies) if company: positions = position.get_positions(company) ui.print_company(company, positions) else: ui.print_notification("No company found with that ID!")
def create(companies): inputs = ui.get_inputs(["Name: "]) if common.check_company_name(companies, inputs[0]): companies.append(Company(common.generate_id(companies), *inputs)) ui.print_notification("Company added!") else: ui.print_notification("Company name already exists!")
def read(positions): position = common.check_id(positions) if position: apps = application.get_applications_by_position_id(position.ID) students = student.get_students_from_applications(apps) ui.print_position(position, students) else: ui.print_notification("No position found with that ID!")
def update(companies): company = common.check_id(companies) if company: inputs = ui.get_inputs(["Name: "]) if common.check_company_name(companies, inputs[0]): company.name = inputs[0] else: ui.print_notification("Cannot change company name to " + inputs[0] + " because it already exists!") else: ui.print_notification("No company found with that ID!")
def read(students): student = common.check_id(students) if student: apps = application.get_applications_by_student_id(student.ID) position_descs = position.get_positions_description(apps) company_ids = position.get_positions_id_by_applications(apps) company_names = company.get_company_names(company_ids) ui.print_student(student, position_descs, company_names) else: ui.print_notification("No student found with that ID!")
def create(positions): inputs = ui.get_inputs(["Description: ", "Seats: ", "Company ID: "]) allowed = True if not inputs[0]: ui.print_notification("Descriptions cannot be empty!") allowed = False try: if int(inputs[1]) < 1: ui.print_notification("Seats must be greater than 0!") allowed = False except ValueError: ui.print_notification("Only numbers are allowed!") if inputs[2] not in company.get_company_ids(): ui.print_notification("Wrong company ID!") allowed = False if allowed: positions.append(Position(common.generate_id(positions), *inputs)) ui.print_notification("Position added!")
def create(students): inputs = ui.get_inputs( ["Name: ", "Age: ", "Status (1 - activated, 0 - deactivated): "]) allowed = True try: if int(inputs[1]) > 100 and int(inputs[1]) < 16: ui.print_notification("Wrong age! (16-99)") allowed = False except ValueError: ui.print_notification("Only numbers are allowed!") try: if int(inputs[2]) > 1 or int(inputs[2]) < 0: ui.print_notification("Status could be only either 1 or 0!") allowed = False except ValueError: ui.print_notification("Only numbers are allowed!") if allowed: ui.print_notification("Student added!") students.append(Student(common.generate_id(students), *inputs))
def delete(companies): company = common.check_id(companies) if company: if not position.get_positions(company): companies.remove(company) ui.print_notification("Company " + company.name + " deleted.") else: ui.print_notification("This company has positions!") else: ui.print_notification("No company found with that ID!")
def delete(students, id_=0): student = common.check_id(students) if student: if not application.get_applications_by_student_id(student.ID): students.remove(student) ui.print_notification(student.name + " deleted.") else: ui.print_notification("This student has applications!") else: ui.print_notification("No student found with that ID!")
def delete(positions, id_=0): position = common.check_id(positions) if position: if not application.get_applications_by_position_id(position.ID): positions.remove(position) ui.print_notification("Position " + position.description + " deleted.") else: ui.print_notification("This position has applications!") else: ui.print_notification("No position found with that ID!")
def change_status(students): student = common.check_id(students) if student: if student.status == "1": student.status = "0" ui.print_notification("Status changed to: 0 (deactivated)") else: student.status = "1" ui.print_notification("Status changed to: 1 (activated)") else: ui.print_notification("No student found with that ID!")
def update(applications): application = common.check_id(applications) if application: inputs = ui.get_inputs(["Status"]) taken_seats = position.get_taken_seats()[0] max_seats = position.get_taken_seats()[1] for i in range(len(max_seats)): if max_seats[i].ID == application.position_id: if inputs[0] == "1": if taken_seats[i] >= int(max_seats[i].seats): ui.print_notification("Status can't be changed! Seats are already full!") else: application.status = inputs[0] ui.print_notification("Status successfully changed.") else: ui.print_notification("No application found with that ID!")
def create(applications): inputs = ui.get_inputs( ["Status: ", "Student ID: ", "Position ID: "]) allowed = True try: if int(inputs[0]) > 1 or int(inputs[0]) < 0: ui.print_notification("Status could be only either 1 or 0!") allowed = False except ValueError: ui.print_notification("Only numbers are allowed!") if inputs[1] not in student.get_students_id(): ui.print_notification("Wrong student ID!") allowed = False if inputs[2] not in position.get_positions_id(): ui.print_notification("Wrong position ID!") allowed = False for application in applications: if inputs[2] == application.position_id and inputs[1] == application.student_id: ui.print_notification("Student already applied to this position!") allowed = False #break if inputs[0] == "1": #check if the user can create an application and not exceeded the available seats taken_seats = position.get_taken_seats()[0] max_seats = position.get_taken_seats()[1] for i in range(len(max_seats)): if max_seats[i].ID == inputs[2]: if taken_seats[i] >= int(max_seats[i].seats): ui.print_notification("Position is full!") allowed = False if allowed: applications.append(Application(common.generate_id(applications), *inputs)) ui.print_notification("Application added!")