|
| 1 | +from src.manage_itineraries import add_itinerary, edit_itinerary, view_itineraries, delete_itinerary, export_itinerary |
| 2 | +from pick import pick |
| 3 | + |
| 4 | + |
| 5 | +def user_task_request(request, itinerary_list): |
| 6 | + ''' |
| 7 | + Executes a specific request based on user's choice. |
| 8 | + ''' |
| 9 | + # Add a new itinerary |
| 10 | + if request == "1": |
| 11 | + flights_list_done = False |
| 12 | + attractions_list_done = False |
| 13 | + print("How exciting! Please provide us information about the trip: \n") |
| 14 | + name = input("Title of the itinerary: ") |
| 15 | + location = input("Location (NA if not applicable): ") |
| 16 | + summary = input("Brief description of trip: ") |
| 17 | + start_date = input("Start date in DD-MM-YYYY: ") |
| 18 | + end_date = input("End date in DD-MM-YYYY: ") |
| 19 | + while not flights_list_done: |
| 20 | + # Answer format: Perth-Sydney 12-12-2012, Sydney-Perth 21-12-2012 |
| 21 | + flights = input("") # dictionary - add loop here |
| 22 | + if flights == "DONE": |
| 23 | + flights_list_done = True |
| 24 | + while not attractions_list_done: |
| 25 | + attractions = input("") # dictionary - add loop here |
| 26 | + if attractions == "DONE": |
| 27 | + attractions_list_done = True |
| 28 | + add_itinerary(itinerary_list, name, location, summary, start_date, end_date, flights, attractions) |
| 29 | + pass |
| 30 | + |
| 31 | + # Edit existing itinerary |
| 32 | + elif request == "2": |
| 33 | + # Use pickpack module (https://github.com/anafvana/pickpack#map-function-for-nested-lists) |
| 34 | + pass |
| 35 | + |
| 36 | + # View itinerary |
| 37 | + elif request == "3": |
| 38 | + view_itineraries(itinerary_list) |
| 39 | + pass |
| 40 | + |
| 41 | + # Delete itinerary |
| 42 | + elif request == "4": |
| 43 | + delete_itinerary(itinerary_list) |
| 44 | + pass |
| 45 | + |
| 46 | + elif request == "5": |
| 47 | + # Export to .csv file? |
| 48 | + # Use pick (not pickpack) library to list itineraries by name and location |
| 49 | + export_itinerary(itinerary_list) |
| 50 | + pass |
| 51 | + |
| 52 | + else: |
| 53 | + print("Invalid answer, please type a number between 1-5.") |
| 54 | + pass |
| 55 | + |
| 56 | + |
| 57 | +def run_app(): |
| 58 | + """ |
| 59 | + Main loop to run the travel planner. |
| 60 | + """ |
| 61 | + itineraries = [] |
| 62 | + app_running = True |
| 63 | + |
| 64 | + while app_running: |
| 65 | + print("Welcome to the Travel Itinerary Planner app!\n") |
| 66 | + print("1. Add a new Itinerary") |
| 67 | + print("2. Edit an existing Itinerary") |
| 68 | + print("3. View existing Itineraries") |
| 69 | + print("4. Delete an Itinerary") |
| 70 | + print("5. Export an Itinerary") |
| 71 | + print("6. Log out\n") |
| 72 | + |
| 73 | + user_choice = input("Please select one of the above options (1-5): ") |
| 74 | + |
| 75 | + # Check user_choice was a number |
| 76 | + if user_choice.isdigit(): |
| 77 | + choice = int(user_choice) |
| 78 | + if 1 <= choice <= 6: |
| 79 | + if user_choice == "6": |
| 80 | + app_running = False |
| 81 | + else: |
| 82 | + user_task_request(user_choice, itineraries) |
| 83 | + else: |
| 84 | + print("Enter a number between 1-6.") |
| 85 | + else: |
| 86 | + ("Invalid input: Please enter a number between 1-6.") |
| 87 | + |
| 88 | + print("See you next time! 👋") |
| 89 | + pass |
| 90 | + |
| 91 | + |
| 92 | +if __name__ == "__main__": |
| 93 | + run_app() |
0 commit comments