Пример #1
0
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))
Пример #2
0
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.")
    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))
Пример #4
0
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))
Пример #5
0
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))
Пример #6
0
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_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}'
    )
Пример #8
0
def view_your_snakes():
    print(' ****************** Your snakes **************** ')
    if not state.active_account:
        error_msg("You must log in first to view your snakes")
        return

    snakes = svc.get_snakes_for_user(state.active_account.id)
    print("You have {} snakes.".format(len(snakes)))
    for s in snakes:
        print(" * {} is a {} that is {}m long and is {}venomous.".format(
            s.name, s.species, s.length, '' if s.is_venomous else 'not '))
Пример #9
0
def view_your_bitches():
    print(' ****************** Your bitches **************** ')
    if not state.active_account:
        error_msg("You must log in first to view your snakes")
        return

    bitches = svc.get_bitches_for_user(state.active_account.id)
    print("You have {} bitches.".format(len(bitches)))
    for s in bitches:
        print(" * {} is a {} that is {}cruel.".format(
            s.name, s.functions, '' if s.is_cruel else 'not '))
Пример #10
0
def view_districts():
    print(' ****************** Districts **************** ')
    if not state.active_account:
        error_msg("You must log in first to get districts")
        return

    districts = svc.get_districts()
    print("There are {} districts.".format(len(districts)))
    for s in districts:
        print(" * District {} has attendance {} and enrollment {}.".format(
            s.district, s.attendance, s.enrol))
def list_snakes(suppress_header=False):
    if not suppress_header:
        print(' ****************** Your snakes **************** ')

    if not state.active_account:
        error_msg('You must login first to list your snake/s.')
        return

    snakes = svc.find_snakes_for_user(state.active_account)
    print(f'You have {len(snakes)} snakes.')
    for idx, s in enumerate(snakes):
        print(f' {idx+1}. {s.name} is a {s.species} that is {s.length}m long '
              f'and is {"" if s.venomous else "not "}venomous.')
Пример #12
0
def view_his_schools():
    print(' ****************** Your saved schools **************** ')
    if not state.active_account:
        error_msg("You must log in first to view your schools")
        return

    schools = svc.get_schools_for_user(state.active_account.id)
    print("You have {} schools.".format(len(schools)))
    for s in schools:
        print(
            " * {} has a DBN {}, average math score {}, average reading score {}, average writing score {}."
            .format(s.name, s.dbn, s.math_score, s.reading_score,
                    s.writing_score))
Пример #13
0
def view_your_snakes():
    print(' ****************** Your snakes **************** ')

    if not state.active_account:
        error_msg('You must login first to view your snakes.')
        return

    snakes = svc.get_snakes_for_user(state.active_account.id)
    print(f'You have {len(snakes)} snakes.')
    for s in snakes:
        print(
            f" * {s.name} is a {s.species} that is "
            f"{s.length}m long and is {('' if s.is_venomous else 'not ')}venomous."
        )
Пример #14
0
def view_your_snakes():
    print(' ****************** Your snakes **************** ')

    if not state.active_account:
        hosts.error_msg('You must log in first to add a snake!')
        return

    snakes = svc.get_snakes_for_user(state.active_account.id)
    print('You have {} snakes.'.format(len(snakes)))

    for s in snakes:
        print(' * {} is a {} that is {} meters in length, and is {}venomous.'.
              format(s.name, s.species, s.length,
                     '' if s.is_venomous else 'not '))
Пример #15
0
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))
Пример #16
0
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.")
Пример #17
0
def view_your_cats(suppress_header=False):
    if not suppress_header:
        print(' ****************** Your cats **************** ')
    if not state.active_account:
        error_msg("You must log in first to view your cats")
        return

    cats = svc.get_cats_for_user(state.active_account.id)
    print("You have {} cats.".format(len(cats)))
    for idx, s in enumerate(cats):
        print(Fore.LIGHTBLUE_EX + 'Cat no. : ' + str(idx + 1) + Fore.WHITE)
        print(f'name : {s.name}')
        print(f'species : {s.species}')
        print(f'height : {s.height}')
        print(f'Angry? : {s.is_angry}')
Пример #18
0
def view_your_snakes(show_header=True):
    if show_header:
        print(' ****************** Your snakes **************** ')

    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)
    print(f'You have {len(snakes)} snakes')

    for idx, s in enumerate(snakes):
        print(
            f" {idx + 1}. {s.name} is a {s.species} that is {s.length}m long and is"
            f"{'' if s.is_venomous else ' not'} venomous")
def view_your_snakes():
    print(' ****************** Your snakes **************** ')
    if not state.active_account:
        error_msg("You must log in first to view your snakes")
        return

    snakes = svc.get_snakes_for_user(state.active_account.id)
    print("You have {} snakes.".format(len(snakes)))
    for s in snakes:
        print(" * {} is a {} that is {}m long and is {}venomous.".format(
            s.name,
            s.species,
            s.length,
            '' if s.is_venomous else 'not '
        ))
Пример #20
0
def view_your_snakes(suppress_header=False):
    if not suppress_header:
        print(' ****************** Your snakes **************** ')
    if not state.active_account:
        error_msg("You must log in first to view your snakes")
        return

    snakes = svc.get_snakes_for_user(state.active_account.id)
    print("You have {} snakes.".format(len(snakes)))
    for idx, s in enumerate(snakes):
        print(Fore.LIGHTBLUE_EX + 'Snake no : ' + str(idx + 1) + Fore.WHITE)
        print(f'name : {s.name}')
        print(f'species : {s.species}')
        print(f'length : {s.length}')
        print(f'Venomous? : {s.is_venomous}')
def view_bookings():
    print(' ****************** Your bookings **************** ')
    # Require an account
    if not state.active_account:
        error_msg('You must [l]ogin first to book a cage.')
        return

    # Get the bookings
    bookings = svc.find_bookings_for_user(state.active_account)

    # List booking info along with snake info
    snakes = {s.id: s for s in svc.find_snakes_for_user(state.active_account)}
    for idx, b in enumerate(bookings):
        print(f' {idx+1}. {snakes.get(b.guest_snake_id).name} is booked at '
              f'{b.cage.name} starting on {b.check_in_date.date()} for '
              f'{(b.check_out_date - b.check_in_date).days} days.')
Пример #22
0
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))
Пример #23
0
def view_bookings():
    print(' ****************** Your bookings **************** ')
    if not state.active_account:
        error_msg("You must log in first to view bookings")
        return

    cats = {s.id: s for s in svc.get_cats_for_user(state.active_account.id)}
    bookings = svc.get_bookings_for_user(state.active_account)
    print()
    print("You have {} bookings.".format(len(bookings)))
    for b in bookings:
        print(' * Cat: {} is booked at {} from {} for {} days.'.format(
            cats.get(b.guest_cat_id).name, b.cage.name,
            datetime.date(b.check_in_date.year, b.check_in_date.month,
                          b.check_in_date.day),
            (b.check_out_date - b.check_in_date +
             datetime.timedelta(seconds=1)).days))
Пример #24
0
def view_bookings():
    print(' ****************** Your bookings **************** ')
    if not state.active_account:
        error_msg("You must log in first to register a shelter")
        return

    pets = {s.id: s for s in svc.get_pets_for_user(state.active_account.id)}
    bookings = svc.get_bookings_for_user(state.active_account.email)

    print("You have {} bookings.".format(len(bookings)))
    for b in bookings:
        # noinspection PyUnresolvedReferences
        print(' * pet: {} is booked at {} from {} for {} days.'.format(
            pets.get(b.guest_pet_id).name, b.shelter.name,
            datetime.date(b.check_in_date.year, b.check_in_date.month,
                          b.check_in_date.day),
            (b.check_out_date - b.check_in_date).days))
Пример #25
0
def view_bookings():
    print(' ****************** Your bookings **************** ')
    if not state.active_account:
        error_msg("You must log in first 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.email)

    print("You have {} bookings.".format(len(bookings)))
    for b in bookings:
        print(' * Snake: {} is booked at {} from {} for {} days.'.format(
            snakes.get(b.guest_snake_id).name,
            b.cage.name,
            datetime.date(b.check_in_date.year, b.check_in_date.month, b.check_in_date.day),
            (b.check_out_date - b.check_in_date).days
        ))
def view_bookings():
    print(' ****************** Your bookings **************** ')
    if not state.active_account:
        error_msg("You must log in first 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.email)

    print("You have {} bookings.".format(len(bookings)))
    for b in bookings:
        print(' * Snake: {} is booked at {} from {} for {} days.'.format(
            snakes.get(b.guest_snake_id).name,
            b.cage.name,
            datetime.date(b.check_in_date.year, b.check_in_date.month, b.check_in_date.day),
            (b.check_out_date - b.check_in_date).days
        ))
Пример #27
0
def view_guests():
    # Require an active account
    if not state.active_account:
        hosts.error_msg("Please login first to register a guest!")
        return

    # Get guests from DB, show details list
    guests = db_svc.find_guests_for_user(state.active_account.email)
    print(' ****************** {}\'s Guests ****************'.format(
        state.active_account.first_name))
    for i, guest in enumerate(guests):
        print("{}. {} {} is a guest with age {}, email {}, "
              "gender {}, and phone {}".format(i + 1, guest.first_name,
                                               guest.last_name, guest.age,
                                               guest.email, guest.gender,
                                               guest.phone_number))
    print(" ****************** END **************** ")
Пример #28
0
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))
Пример #29
0
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:
        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))
Пример #31
0
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}')
Пример #32
0
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))
Пример #33
0
def view_bookings():
    print(' ****************** Your bookings **************** ')
    # Require an active account
    if not state.active_account:
        hosts.error_msg("Please login first to register a guest!")
        return

    guests = {
        g.id: g
        for g in db_svc.find_guests_for_user(state.active_account.email)
    }
    bookings = db_svc.get_bookings_for_user(state.active_account.email)

    print("You have {} bookings.".format(len(bookings)))
    for b in bookings:
        # noinspection PyUnresolvedReferences
        print(' * Guest: {} {} is booked at {} from {} for {} days.'.format(
            guests.get(b.guest_id).first_name,
            guests.get(b.guest_id).last_name, b.room.number,
            b.check_in_date.date(), b.duration_in_days))
Пример #34
0
def view_bookings():
    print(' ****************** Your bookings **************** ')

    if not state.active_account:
        error_msg('You must login first to view your bookings.')
        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.email)

    print(f"You have {len(bookings)} bookings.")
    for b in bookings:
        print(
            f" * Snake: {snakes.get(b.guest_snake_id).name} is booked at"
            f" {b.cage.name} from "
            f"{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.")