def viewProjects(): # view project sub menu viewProjectsMenu = Menu( "Choice: ", ["One Project", "Completed", "All Projects", "Back"]) while True: Common.cls() print("--- VIEW PROJECTS ---") choice, errorMsg = viewProjectsMenu.show() if errorMsg: print(errorMsg) Common.pause() continue if choice == 1: # One project viewProjectsOneProject() elif choice == 2: viewProjectsCompletedProjects() elif choice == 3: viewProjectsAllProjects() elif choice == 4: break
def inputProjectDetails(): fileManager = FileManager() Common.cls() print("--- INPUT PROJECT DETAILS ---") newId = fileManager.getNewId() print("Project ID: {}".format(newId)) try: title = input("Title: ") if len(title) < 1: raise TypeError size = int(input("Size (number of pages): ")) if size < 1: raise ValueError priority = int(input("Priority: ")) if priority < 1: raise ValueError except ValueError: print("Please enter a positive integer.") Common.pause() return except TypeError: print("Title must not be empty.") Common.pause() return fileManager.appendRecord([[newId, title, size, priority, "False"]])
def main(): # instantiate menu class mainMenu = Menu("Choice: ", [ "Input Project Details", "View Projects", "Schedule Projects", "Get A Project", "Exit" ]) # program loop while True: Common.cls() print("--- COPY TYPING SCHEDULER ---") choice, errorMsg = mainMenu.show() if errorMsg: print(errorMsg) Common.pause() continue # main menu if choice == 1: # Input Project Details inputProjectDetails() elif choice == 2: # View Projects viewProjects() elif choice == 3: # Schedule Project scheduleProjects() elif choice == 4: # Get A Project getProject() elif choice == 5: # Exit exit()
def scheduleProjectsCreateSchedule(): fileManager = FileManager() fileManager.writeScheduleCSV() Common.cls() print("---CREATE SCHEDULE---") print("Schedule Created!") Common.pause()
def scheduleProjectsViewSchedule(): fileManager = FileManager() Common.cls() print("--- VIEW UPDATED SCHEDULE ---") schedule = fileManager.viewUpdatedSchedule() if schedule: for project in schedule: print("Project ID: {}".format(project[0])) print("Title: {}".format(project[1])) print("Size: {}".format(project[2])) print("Priority: {}".format(project[3])) print("----------") else: print("There is no schedule created yet. Do it now.") Common.pause()
def viewProjectsCompletedProjects(): fileManager = FileManager() Common.cls() print("--- VIEW PROJECTS: COMPLETED ---") completedProjects = fileManager.getAllCompletedProjects() if completedProjects: for project in completedProjects: print("Project ID: {}".format(project[0])) print("Title: {}".format(project[1])) print("Size: {}".format(project[2])) print("Priority: {}".format(project[3])) print("----------") else: print("There is no projects completed yet.") Common.pause()
def viewProjectsAllProjects(): fileManager = FileManager() Common.cls() print("--- VIEW PROJECTS: ALL ---") allProjects = fileManager.getAllProjects() if allProjects: for project in allProjects: print("Project ID: {}".format(project[0])) print("Title: {}".format(project[1])) print("Size: {}".format(project[2])) print("Priority: {}".format(project[3])) print("Completed: {}".format(project[4])) print("----------") else: print("There is no projects entered yet.") Common.pause()
def scheduleProjects(): # schedule projects sub menu scheduleProjectsMenu = Menu( "Choice: ", ["Create Schedule", "View Updated Schedule", "Back"]) while True: Common.cls() print("---SCHEDULE PROJECTS ---") choice, errorMsg = scheduleProjectsMenu.show() if errorMsg: print(errorMsg) Common.pause() continue if choice == 1: scheduleProjectsCreateSchedule() elif choice == 2: scheduleProjectsViewSchedule() elif choice == 3: break
def viewProjectsOneProject(): fileManager = FileManager() try: projectID = input("Enter Project ID: ") if int(projectID) not in range(1, fileManager.getNewId()): raise ValueError except ValueError: print("Project with ID {} does not exist.".format(projectID)) Common.pause() return project = fileManager.getProjectInfo(projectID) Common.cls() print("--- VIEW PROJECTS: {} ---".format(project[1])) print("Project ID: {}".format(project[0])) print("Title: {}".format(project[1])) print("Size: {}".format(project[2])) print("Priority: {}".format(project[3])) print("Completed: {}".format(project[4])) Common.pause()
def getProject(): fileManager = FileManager() # Display schedule Common.cls() print("--- PROJECT SCHEDULE ---") schedule = fileManager.viewUpdatedSchedule() if schedule: for project in schedule: print("Project ID: {}".format(project[0])) print("Title: {}".format(project[1])) print("Size: {}".format(project[2])) print("Priority: {}".format(project[3])) print("----------") else: print("There is no schedule created yet. Do it now.") Common.pause() return input("Press ENTER to get a project...") # update projects and schedule fileManager.updateCompletionCSV(schedule[0][0]) Common.cls() print("--- PROJECT SCHEDULE ---") print("Topmost project has been removed from queue.") Common.pause() Common.cls() print("--- NEW PROJECT SCHEDULE ---") schedule = fileManager.viewUpdatedSchedule() if schedule: for project in schedule: print("Project ID: {}".format(project[0])) print("Title: {}".format(project[1])) print("Size: {}".format(project[2])) print("Priority: {}".format(project[3])) print("----------") else: print("There is nothing in the queue anymore.") Common.pause()