Beispiel #1
0
def phone_saver(name: str, phones: str) -> bool:
    """Gets `name` and `phones` and saves them as related objects in DB 

    Args:
        name (str): Contact name
        phones (str): Contact's phones, separated by `\\n` 

    Returns:
        bool: Operation success status
    """
    if name and phones:
        user = User.add(name)
        for phone in phones.split("\n"):
            Phone.add(phone, user)
        return True
    return False
Beispiel #2
0
def add_phone_controller(user, cls=True):
    render_template(context={}, template="add_phone.jinja2", cls=cls)
    phone_number = input()
    phone = Phone.add(phone_number, user)
    return 212, user # (next state, data)