def add_a_cat(): print(' ****************** Add a cat **************** ') if not state.active_account: error_msg("You must log in first to add a cat") return name = str(input("What is your cat's name? ")) if not (name.strip(' ')): error_msg('name cannot be empty') return height = input('Height your cat (in meters)? ') if not height: error_msg('Height is mandatory') return try: height = float(height) except ValueError: error_msg('Invalid height') return species = input("Species? ") if not (name.strip(' ')): error_msg('species cannot be empty') return not_angry = input( "Is your cat angry by nature [y]es, [n]o? ").lower().startswith('n') is_angry = not not_angry cat = svc.add_cat(state.active_account, name, height, species, is_angry) state.reload_account() success_msg('Created {} with id {}'.format(cat.name, cat.id))
def add_a_snake(): print(' ****************** Add a snake **************** ') if not state.active_account: error_msg("You must log in first to add a snake") return name = str(input("What is your snake's name? ")) if not (name.strip(' ')): error_msg('name cannot be empty') return length = input('How long is your snake (in meters)? ') if not length: error_msg('Length is mandatory') return try: length = float(length) except ValueError: error_msg('Invalid length') return species = input("Species? ") if not (name.strip(' ')): error_msg('species cannot be empty') return not_venomous = input( "Is your snake venomous [y]es, [n]o? ").lower().startswith('n') is_venomous = not not_venomous snake = svc.add_snake(state.active_account, name, length, species, is_venomous) state.reload_account() success_msg('Created {} with id {}'.format(snake.name, snake.id))
def book_a_cage(): print(' ****************** Book a cage **************** ') if not state.active_account: error_msg("You must log in first to book a cage") return snakes = svc.get_snakes_for_user(state.active_account.id) if not snakes: error_msg('You must first [a]dd a snake before you can book a cage.') return print("Let's start by finding available cages.") try: checkin = parser.parse(input("Check-in date [yyyy-mm-dd]: ")) checkout = parser.parse(input("Check-out date [yyyy-mm-dd]: ")) except: error_msg('Invalid inputs') return checkout = checkout + datetime.timedelta(days=1) - datetime.timedelta( seconds=1) if checkin >= checkout: error_msg('Check in must be before check out') return print() view_your_snakes(suppress_header=True) print() try: snake = snakes[int(input('Which snake do you want to book (number)')) - 1] except: error_msg('Invalid inputs') return cages = svc.get_available_cages(checkin, checkout, snake) print("There are {} cages available in that time.".format(len(cages))) print() for idx, c in enumerate(cages): print(" {}. {} with {}sq.m at ${}/night. carpeted: {}, has toys: {}.". format(idx + 1, c.name, c.square_meters, c.price, 'yes' if c.is_carpeted else 'no', 'yes' if c.has_toys else 'no')) if not cages: error_msg("Sorry, no cages are available for that date.") return try: cage = cages[int(input('Which cage do you want to book (number)')) - 1] except: error_msg('Invalid inputs') return svc.book_cage(state.active_account, snake, cage, checkin, checkout) success_msg('Successfully booked {} for {} at ${}/night.'.format( cage.name, snake.name, cage.price))
def book_a_cage(): print(' ****************** Book a cage **************** ') if not state.active_account: error_msg("You must log in first to book a cage") return snakes = svc.get_snakes_for_user(state.active_account.id) if not snakes: error_msg('You must first [a]dd a snake before you can book a cage.') return print("Let's start by finding available cages.") start_text = input("Check-in date [yyyy-mm-dd]: ") if not start_text: error_msg('cancelled') return checkin = parser.parse( start_text ) checkout = parser.parse( input("Check-out date [yyyy-mm-dd]: ") ) if checkin >= checkout: error_msg('Check in must be before check out') return print() for idx, s in enumerate(snakes): print('{}. {} (length: {}, venomous: {})'.format( idx + 1, s.name, s.length, 'yes' if s.is_venomous else 'no' )) snake = snakes[int(input('Which snake do you want to book (number)')) - 1] cages = svc.get_available_cages(checkin, checkout, snake) print("There are {} cages available in that time.".format(len(cages))) for idx, c in enumerate(cages): print(" {}. {} with {}m carpeted: {}, has toys: {}.".format( idx + 1, c.name, c.square_meters, 'yes' if c.is_carpeted else 'no', 'yes' if c.has_toys else 'no')) if not cages: error_msg("Sorry, no cages are available for that date.") return cage = cages[int(input('Which cage do you want to book (number)')) - 1] svc.book_cage(state.active_account, snake, cage, checkin, checkout) success_msg('Successfully booked {} for {} at ${}/night.'.format(cage.name, snake.name, cage.price))
def book_a_cage(): print(' ****************** Book a cage **************** ') if not state.active_account: error_msg("You must log in first to book a cage") return snakes = svc.get_snakes_for_user(state.active_account.id) if not snakes: error_msg('You must first [a]dd a snake before you can book a cage.') return print("Let's start by finding available cages.") start_text = input("Check-in date [yyyy-mm-dd]: ") if not start_text: error_msg('cancelled') return checkin = parser.parse( start_text ) checkout = parser.parse( input("Check-out date [yyyy-mm-dd]: ") ) if checkin >= checkout: error_msg('Check in must be before check out') return print() for idx, s in enumerate(snakes): print('{}. {} (length: {}, venomous: {})'.format( idx + 1, s.name, s.length, 'yes' if s.is_venomous else 'no' )) snake = snakes[int(input('Which snake do you want to book (number)')) - 1] cages = svc.get_available_cages(checkin, checkout, snake) print("There are {} cages available in that time.".format(len(cages))) for idx, c in enumerate(cages): print(" {}. {} with {}m carpeted: {}, has toys: {}.".format( idx + 1, c.name, c.square_meters, 'yes' if c.is_carpeted else 'no', 'yes' if c.has_toys else 'no')) if not cages: error_msg("Sorry, no cages are available for that date.") return cage = cages[int(input('Which cage do you want to book (number)')) - 1] svc.book_cage(state.active_account, snake, cage, checkin, checkout) success_msg('Successfully booked {} for {} at ${}/night.'.format(cage.name, snake.name, cage.price))
def book_a_cage(): print(' ****************** Book a cage **************** ') if not state.active_account: hosts.error_msg("Must be logged in to register a cage") return snakes = svc.get_snakes_for_user(state.active_account.id) if not snakes: hosts.error_msg( f'No snakes found for user {state.active_account.name}') return start_text = input("Check-in date for cage [yyyy-mm-dd]: ") if not start_text: hosts.error_msg('Cancelled') return check_in_date = parser.parse(start_text) checkout_date = parser.parse( input("Checkout date for cage [yyyy-mm-dd]: ")) if check_in_date >= checkout_date: hosts.error_msg('Check in date must be prior to checkout date') return print('Select snake to book:') view_your_snakes(show_header=False) snake_number = int(input("Enter snake number: ")) - 1 snake = snakes[snake_number] print('Finding available cages...') cages = svc.get_available_cages(check_in_date, checkout_date, snake) if not cages: hosts.error_msg('No cages available for your date') return print( f'You have {len(cages)} available cage(s) to book. Please select from the following:' ) for idx, c in enumerate(cages): print( f" * {idx + 1}. {c.name}, size: {c.square_metres}m\N{SUPERSCRIPT TWO}, " f"carpeted: {'yes' if c.is_carpeted else 'no'}, " f"toys: {'yes' if c.has_toys else 'no'}, " f"price: {c.price}") cage = cages[int(input('Select cage to book: ')) - 1] cage = svc.book_cage(state.active_account, snake, cage, check_in_date, checkout_date) hosts.success_msg( f'Successfully booked {cage.name} for {snake.name} at £{cage.price}/night' )
def book_room(): print(' ****************** Book a room **************** ') # Require an active account if not state.active_account: hosts.error_msg("Please login first to register a guest!") return guests = db_svc.find_guests_for_user(state.active_account.email) # Verify they have a guest if not guests: hosts.error_msg("Please add a guest first!") return print("Lets start finding rooms..") # Get dates and select guest start_date = input("Enter Check in date [YYYY-MM-DD]: ").strip() if not start_date: hosts.error_msg("Cancelled!") return start_date = parser.parse(start_date) end_date = parser.parse(input("Enter Check out date [YYYY-MM-DD]: ")) if start_date >= end_date: hosts.error_msg("Check in can't be on/after Checkout date") return print("Please choose available guest from the list: ") view_guests() guest_no = int(input("Chosen Guest no?: ").strip()) guest = guests[guest_no - 1] # Find rooms available across date range allow_pets = bool( input("Does this guest has pet(s)? [y/n]: ").strip().startswith('y')) rooms = db_svc.get_available_rooms(start_date, end_date, allow_pets) if not rooms: hosts.error_msg("Sorry, there are no rooms available for that date!") return print("You have {} rooms.".format(len(rooms))) for idx, room in enumerate(rooms): print("{} Room {}, {} type is priced at Rs.{} with pets {}\n".format( idx + 1, room.number, room.rtype, room.price, "allowed" if room.allow_pets else "not allowed")) for b in room.bookings: print(' * Booking: {}, {} days, booked? {}'.format( b.check_in_date, (b.check_out_date - b.check_in_date).days, 'YES' if b.booked_date is not None else 'no')) # Let user select room to book. selected_room = rooms[int(input("Pick a room: ")) - 1] db_svc.book_room(state.active_account, guest, selected_room, start_date, end_date) hosts.success_msg("Room {} booked successfully at Rs.{}/night!".format( selected_room.number, selected_room.price))
def book_a_cage(): print(' ****************** Book a cage **************** ') # Require an account if not state.active_account: error_msg('You must [l]ogin first to book a cage.') return # Verify they have a snake snakes = svc.find_snakes_for_user(state.active_account) if len(snakes) < 1: error_msg('You must first [a]dd a snake before booking a cage.') return # Select snake list_snakes(suppress_header=True) snake_number = input('Enter snake number: ').strip() if not snake_number: error_msg('Cancelled') return snake_number = int(snake_number) snakes = svc.find_snakes_for_user(state.active_account) selected_snake = snakes[snake_number - 1] success_msg(f'Booking a cage for {selected_snake.name}.') # Get dates check_in_date = parser.parse(input('Check-in date [yyyy-mm-dd]: ')) check_out_date = parser.parse(input('Check-out date [yyyy-mm-dd]: ')) if check_in_date >= check_out_date: error_msg('Check in must be before check out.') return # Find cages available across date range cages = svc.find_available_cages(check_in_date, check_out_date, selected_snake) # Let user select cage to book print(f'There are {len(cages)} cages available for those dates.') for idx, c in enumerate(cages): print(f' {idx+1}. ${c.price} - {c.name},' f' {c.square_meters} square meters,' f' it does{"" if c.carpeted else " not"} have carpet,' f' it does{"" if c.has_toys else " not"} have toys.') if not cages: error_msg('Sorry, no cages are available for that date.') return cage_number = int(input('Which cage would you like to book? ')) selected_cage = cages[cage_number - 1] svc.book_cage(state.active_account, selected_cage, selected_snake, check_in_date, check_out_date) success_msg( f'Booked {selected_cage.name} from {check_in_date} to {check_out_date}' )
def book_a_cage(): print(' ****************** Book a cage **************** ') if not state.active_account: error_msg('You must login first to book a cage.') return snakes = svc.get_snakes_for_user(state.active_account.id) if not snakes: error_msg('You must first [a]dd a snake before you can book a cage.') return print("Let's start by finding available cages") start_text = input("Check in date [yyyy-mm-dd]? ") if not start_text: error_msg('Cancelled') return checkin = parser.parse(start_text) checkout = parser.parse(input("Check out date [yyyy-mm-dd]? ")) if checkin > checkout: error_msg('Check in must be before checkout') return print() for idx, s in enumerate(snakes): print(f"{(idx + 1)}. {s.name} (length: {s.length}m, " f"venomous: {('yes' if s.is_venomous else 'no')})") snake = snakes[int(input("Which snake do you want book for (number)")) - 1] cages = svc.get_available_cages(checkin, checkout, snake) if not cages: error_msg('Sorry, no cages available for that date') print(f"There are {len(cages)} available during that time.") for idx, c in enumerate(cages): print(f" {(idx + 1)}. {c.name} with {c.square_meters}m, " f"carpeted: {('yes' if c.is_carpeted else 'no')}" f"has toys: {('yes' if c.has_toys else 'no')}.") cage = cages[int(input('Which cage would you like to book (number)? ')) - 1] svc.book_cage(state.active_account, snake, cage, checkin, checkout) success_msg(f"Successfully booked {cage.name} for {snake.name} " f"at €{cage.price} per night.")
def book_a_shelter(): print(' ****************** Book a shelter **************** ') if not state.active_account: error_msg("You must log in first to book a shelter") return pets = svc.get_pets_for_user(state.active_account.id) if not pets: error_msg('You must first [a]dd a pet before you can book a shelter.') return print("Let's start by finding available shelters.") start_text = input("Check-in date [yyyy-mm-dd]: ") if not start_text: error_msg('cancelled') return checkin = parser.parse(start_text) checkout = parser.parse(input("Check-out date [yyyy-mm-dd]: ")) if checkin >= checkout: error_msg('Check in must be before check out') return print() for idx, s in enumerate(pets): print('{}. {} (length: {}, venomous: {})'.format( idx + 1, s.name, s.length, 'yes' if s.is_venomous else 'no')) pet = pets[int(input('Which pet do you want to book (number)')) - 1] shelters = svc.get_available_shelters(checkin, checkout, pet) print("There are {} shelters available in that time.".format( len(shelters))) for idx, c in enumerate(shelters): print(" {}. {} with {}m carpeted: {}, has toys: {}.".format( idx + 1, c.name, c.square_meters, 'yes' if c.is_carpeted else 'no', 'yes' if c.has_toys else 'no')) if not shelters: error_msg("Sorry, no shelters are available for that date.") return shelter = shelters[int(input('Which shelter do you want to book (number)')) - 1] svc.book_shelter(state.active_account, pet, shelter, checkin, checkout) success_msg('Successfully booked {} for {} at ${}/night.'.format( shelter.name, pet.name, shelter.price))
def book_a_room(): print(' ****************** Book a room **************** ') if not state.active_account: error_msg("You must log in first to book a cage") return bitches = svc.get_bitches_for_user(state.active_account.id) if not bitches: error_msg('You must first [a]dd a bitch before you can book a room.') return print("Let's start by finding available rooms.") start_text = input("Check-in date [yyyy-mm-dd]: ") if not start_text: error_msg('cancelled') return checkin = parser.parse(start_text) checkout = parser.parse(input("Check-out date [yyyy-mm-dd]: ")) if checkin >= checkout: error_msg('Check in must be before check out') return print() for idx, s in enumerate(bitches): print('{}. {} (cruel: {})'.format(idx + 1, s.name, 'yes' if s.is_cruel else 'no')) bitch = bitches[int(input('Which bitch do you want to book (number)')) - 1] rooms = svc.get_available_rooms(checkin, checkout, bitch) print("There are {} rooms available in that time.".format(len(rooms))) for idx, c in enumerate(rooms): print(" {}. {} with {}m milf: {}, has instruments: {}.".format( idx + 1, c.name, 'yes' if c.is_milf else 'no', 'yes' if c.has_instruments else 'no')) if not rooms: error_msg("Sorry, no rooms are available for that date.") return room = rooms[int(input('Which room do you want to book (number)')) - 1] svc.book_room(state.active_account, bitch, room, checkin, checkout) success_msg('Successfully booked {} for {} at ${}/night.'.format( room.name, bitches.name, room.price))
def add_a_snake(): print(' ****************** Add a snake **************** ') if not state.active_account: error_msg("You must log in first to add a snake") return name = input("What is your snake's name? ") if not name: error_msg('cancelled') return length = float(input('How long is your snake (in meters)? ')) species = input("Species? ") is_venomous = input("Is your snake venomous [y]es, [n]o? ").lower().startswith('y') snake = svc.add_snake(state.active_account, name, length, species, is_venomous) state.reload_account() success_msg('Created {} with id {}'.format(snake.name, snake.id))
def add_a_bitch(): print(' ****************** Add a bitch **************** ') if not state.active_account: error_msg("You must log in first to add a bitch") return name = input("What is your bitch's name? ") if not name: error_msg('cancelled') return functions = input("Functions? ") is_cruel = input( "Is your bitch want cruel sex [y]es, [n]o? ").lower().startswith('y') bitch = svc.add_bitch(state.active_account, name, functions, is_cruel) state.reload_account() success_msg('Created {} with id {}'.format(bitch.name, bitch.id))
def add_a_snake(): print(' ****************** Add a snake **************** ') if not state.active_account: error_msg("You must log in first to add a snake") return name = input("What is your snake's name? ") if not name: error_msg('cancelled') return length = float(input('How long is your snake (in meters)? ')) species = input("Species? ") is_venomous = input("Is your snake venomous [y]es, [n]o? ").lower().startswith('y') snake = svc.add_snake(state.active_account, name, length, species, is_venomous) state.reload_account() success_msg('Created {} with id {}'.format(snake.name, snake.id))
def add_a_snake(): print(' ****************** Add a snake **************** ') if not state.active_account: hosts.error_msg("Must be logged in to register a cage") return species = input('Species: ') length = float(input('Length (m): ')) venomous = input('Venomous snake (y/n)? ').startswith('y') name = input('Snake name: ') snake = svc.add_snake(state.active_account, name, species, length, venomous) state.reload_account() hosts.success_msg( f'Snake {snake.name} created successfully with id {snake.id}')
def add_guest(): print(' ****************** Add a guest **************** ') # Require an active account if not state.active_account: hosts.error_msg("Please login first to register a guest!") return # Get guest info from guest name = input("Please enter guest name as 'FIRST_NAME LAST_NAME':") email = input("Please enter guest email id:").lower().strip() age = int(input("Please enter guest age:")) phone = input("Please enter guest phone number:") gender = input("Please enter guest gender:") # Create the guest in the DB. guest = db_svc.add_guest(state.active_account, name, email, age, phone, gender) state.reload_account() hosts.success_msg("Added {} {} as a guest".format(guest.first_name, guest.last_name))
def add_a_snake(): print(' ****************** Add a snake **************** ') if not state.active_account: error_msg('You must login first to register a cage.') return name = input('What is the name of your snake? ') if not name: error_msg('Cancelled') return length = float(input('How long is your snake (in meters)? ')) species = input('Species? ') venomous = input('Is your snake venomous [y, n]? ').lower().startswith('y') snake = svc.add_snake(state.active_account, name, species, length, venomous) state.reload_account() success_msg(f'Registered {snake.name} with id {snake.id}.')
def view_bookings(): print(' ****************** Your bookings **************** ') if not state.active_account: hosts.error_msg("Must be logged in to register a cage") return snakes = { s.id: s for s in svc.get_snakes_for_user(state.active_account.id) } bookings = svc.get_bookings_for_user(state.active_account.id) print(f'You have {len(bookings)} booking(s)') b: Booking for b in bookings: hosts.success_msg( f' * Snake: {snakes.get(b.guest_snake_id).name} ' f'is booked in cage {b.cage.name} ' f'from {datetime.date(b.check_in_date.year, b.check_in_date.month, b.check_in_date.day)} ' f'for {(b.check_out_date - b.check_in_date).days} days')
def add_a_snake(): #you can add multiple snakes in this way instead of adding one by one #snakes = [snake1,snake2,snake3.....] #Snake.objects().insert(snakes) print(' ****************** Add a snake **************** ') if not state.active_account: error_msg("You must log in first to add a snake") return name = input("What is your snake's name? ") if not name: error_msg('cancelled') return length = float(input('How long is your snake (in meters)? ')) species = input("Species? ") is_venomous = input( "Is your snake venomous [y]es, [n]o? ").lower().startswith('y') snake = svc.add_snake(state.active_account, name, length, species, is_venomous) state.reload_account() success_msg('Created {} with id {}'.format(snake.name, snake.id))
def add_a_snake(): print(" ****************** Add a snake **************** ") if not state.active_account: error_msg("You must log in first to add a snake") return name = input("What is your snake's name? ") if not name: error_msg("Cancelled") return length = float(input("How long is your snake (in meters)? ")) species = input("Species? ") is_venomous = input( "Is your snake venomous [y]es, [n]o ").lower().startswith("y") snake = svc.add_snake(state.active_account, name, length, species, is_venomous) state.reload_account() success_msg("Created {} with id {}".format( snake.name, snake.id # pylint: disable=no-member ))
def add_a_school(): print(' ****************** Add a school **************** ') print("%s", state.active_account) if not state.active_account: error_msg("You must log in first to add a school") return name = input("What is your school's name? ") if not name: error_msg('cancelled') return dbn = input("What is your school's dbn? ") if not dbn: error_msg('cancelled') return num_takers = input('How many people are taking exam 1? ') reading_score = input('Reading score? ') math_score = input('Math score? ') writing_score = input('Writing score? ') num_takers2 = input('How many people are taking exam 2? ') exam_taken2 = input('How many people have taken exam 2? ') exam_good2 = input('ow many people have taken exam 2 good? ') school = svc.add_school_custom(state.active_account, dbn, name, num_takers, reading_score, math_score, writing_score, num_takers2, exam_taken2, exam_good2) state.reload_account() success_msg('Created {} with id {}'.format(school.name, school.id))