def print_user_help(): if PermissionManager.has_permission_view_users(person): print( "\tuser [<id>] | shows data for user with id or username <id> (if not passed shows for logged user)\n" "\t\tlist | lists all users\n" "\t\t\t[firstname=<firstname>] [lastname=<lastname>] | searches users by <firstname>, <lastname>, or both" ) if PermissionManager.has_permission_add_user(person): print( "\t\tadd | goes through the create user wizard" ) print_divider()
def add_room(person): if PermissionManager.has_permission_add_hotel(person): print( '''You will be guided to enter the new room's data, if you want to cancel type /cancel''' ) desc = input("Description >> ") if desc != '/cancel': number_of_people = input( "Number of people that can fit in the room >> ") if number_of_people != '/cancel': print( "Room data" "\n========================" "\nDescription: " + desc, "\nNumber of people: " + number_of_people) answer = input( "Do you want to add hotel with data above (yes/no) >> ") while answer != "yes" and answer != "no": answer = input( "Unrecognized '" + answer + "'\nDo you want to add hotel with data above (yes/no) >> " ) if answer == "yes": return RoomDAO.add_room(desc, number_of_people) else: print("Forbidden. You are missing necessary permissions.") return False
def add_service(person, service_id, hotel_id, price): if PermissionManager.has_permission_add_hotel(person): ServiceDAO.add_service_to_hotel(hotel_id, service_id, price) return True else: print("Forbidden. You are missing necessary permissions.") return False
def make_reservation(person): if PermissionManager.has_permission_view_hotel(person): print( "You will be guided step by step to make your reservation. If you want to cancel at any point type '/cancel'" ) HotelManager.get_with_options(person, []) hotel_id = input("Choose a hotel by entering its ID >> ") if hotel_id != '/cancel': hotel = HotelDAO.get_by_id(hotel_id) if hotel is not None: from_date = input( "Choose first day of your reservation (YYYY-MM-DD format) >> " ) if from_date != '/cancel': to_date = input( "Choose last day of your reservation (YYYY-MM-DD format) >> " ) if to_date != '/cancel': RoomManager.get_rooms_by_hotel(person, hotel_id) room_id = input("Choose room by entering its ID >> ") if room_id != '/cancel': result = ReservationDAO.make_reservation( person, room_id, from_date, to_date) if result: print("Reservation made successfully.") else: print("Reservation unsuccessful.") return result return False else: print("Forbidden. You are missing necessary permissions.") return False
def add_service(person): if PermissionManager.has_permission_add_hotel(person): print( '''You will be guided to enter the new service's data, if you want to cancel type /cancel''' ) name = input("Name >> ") if name != '/cancel': description = input("Description >> ") if description != '/cancel': print( "Hotel data" "\n========================" "\nName: " + name, "\nDescription: " + description) answer = input( "Do you want to add service with data above (yes/no) >> ") while answer != "yes" and answer != "no": answer = input( "Unrecognized '" + answer + "'\nDo you want to add service with data above (yes/no) >> " ) if answer == "yes": return ServiceDAO.add_service(name, description) else: print("Forbidden. You are missing necessary permissions.") return False
def add_person(person): if PermissionManager.has_permission_add_user(person): print( '''You will be guided to enter the new user's data, if you want to cancel type /cancel''' ) first_name = input("First name >> ") if first_name != '/cancel': last_name = input("Last name >> ") if last_name != '/cancel': username = input("Username used to login >> ") if username != '/cancel': password = input("Password used to login >> ") if password != '/cancel': print( "User data" "\n========================" "\nFirst name: " + first_name, "\nLast name: " + last_name, "\nUsername: "******"\nPassword: "******"Do you want to add user with data above (yes/no) >> " ) while answer != "yes" and answer != "no": answer = input( "Unrecognized '" + answer + "'\nDo you want to add user with data above (yes/no) >> " ) if answer == "yes": return PersonDAO.add_person( first_name, last_name, username, password) else: print("Forbidden. You are missing necessary permissions.") return False
def print_room_help(): if PermissionManager.has_permission_add_hotel(person): print( "\troom\n" "\t\tlist | lists all room types\n" "\t\tadd | goes through the create room type wizard" ) print_divider()
def get_with_options(person, options): if PermissionManager.has_permission_view_hotel(person): results = HotelDAO.get_all_with_options(options) print(format_hotel_header()) for row in results: print(format_hotel(row)) else: print("You don't have the necessary permissions")
def get_all(person): if PermissionManager.has_permission_view_hotel(person): results = ServiceDAO.get_all() print(format_service_header()) for row in results: print(format_service(row)) else: print("Forbidden. You are missing necessary permissions.")
def print_permission_help(): if PermissionManager.has_permission_edit(person): print( "\tpermission | does nothing on its own\n" "\t\tgive <person_id> <permission_id> | gives permission with id or name <permission_id> to user with id or username <person_id>\n" "\t\tlist | lists all permissions\n" "\t\t\t<person_id> | lists permission of user with id or username <person_id>" ) print_divider()
def get_by_hotel(person, hotel_id): if PermissionManager.has_permission_view_hotel(person): results = ServiceDAO.get_by_hotel(hotel_id) print("Services this hotel has to offer:") print(format_hotel_service_header()) for row in results: print(format_hotel_service(row)) else: print("Forbidden. You are missing necessary permissions.")
def print_service_help(): if PermissionManager.has_permission_add_hotel(person): print( "\tservice\n" "\t\tadd | goes through the create service wizard\n" "\t\tlist | shows list of available services\n" "\t\t\t[name=<name>] | option searches by <name>" ) print_divider()
def print_hotel_help(): if PermissionManager.has_permission_view_hotel(person): print( "\thotel <id> | shows data for hotel with id <id>" ) if PermissionManager.has_permission_add_hotel(person): print( "\t\tadd | goes through the create hotel wizard" ) print( "\t\tlist | shows a list of hotels, can be used with none, some or all\n" "\t\t\t[name=<name>] [city=<city>] | the options provided (name, city, country, min_rating\n" "\t\t\t[country=<country>] [min_rating=<min_rating>] |") if PermissionManager.has_permission_add_hotel(person): print( "\t\tadd-service <hotel_id> <service_id> <price> | adds <service_id> to <hotel_id> with price <price>\n" "\t\tadd-rooms <hotel_id> <room_id> <price> <room count> | adds <room count> rooms(<room_id>) to <hotel_id> with <price> per day of stay" ) print_divider()
def get_all(person): if PermissionManager.has_permission_add_hotel(person): results = RoomDAO.get_all() print(format_room_header()) for row in results: print(format_room(row)) return True else: print("Forbidden. You are missing necessary permissions.") return False
def get_rooms_by_hotel(person, hotel_id): if PermissionManager.has_permission_view_hotel(person): results = RoomDAO.get_rooms_by_hotel(hotel_id) print("Hotel Rooms:") print(format_hotel_room_header()) for row in results: print(format_hotel_room(row)) return True else: print("Forbidden. You are missing necessary permissions.") return False
def get(person, hotel_id): if PermissionManager.has_permission_view_hotel(person): hotel = HotelDAO.get_by_id(hotel_id) if hotel: print("Name: " + hotel['name']) print("City: " + hotel['city']) print("Country: " + hotel['country']) print("Rating: " + str(hotel['rating'])) ServiceManager.get_by_hotel(person, hotel_id) RoomManager.get_rooms_by_hotel(person, hotel_id) else: return False else: print("Forbidden. You are missing necessary permissions.") return False
def add_hotel(person): if PermissionManager.has_permission_add_hotel(person): print('''You will be guided to enter the new hotel's data, if you want to cancel type /cancel''') name = input("Name >> ") if name != '/cancel': city = input("City >> ") if city != '/cancel': country = input("Country >> ") if country != '/cancel': print("Hotel data" "\n========================" "\nName: " + name, "\nCity: " + city, "\nCountry: " + country) answer = input("Do you want to add hotel with data above (yes/no) >> ") while answer != "yes" and answer != "no": answer = input("Unrecognized '" + answer + "'\nDo you want to add hotel with data above (yes/no) >> ") if answer == "yes": return HotelDAO.add_hotel(name, city, country) else: print("Forbidden. You are missing necessary permissions.") return False
def add_room(person, hotel_id, room_id, price, count): if PermissionManager.has_permission_add_hotel(person): return RoomDAO.add_room_hotel(hotel_id, room_id, count, price) else: print("Forbidden. You are missing necessary permissions.") return False