Beispiel #1
0
def add_user(name='Sukhiya',
             username='******',
             nationality='Indian',
             age=20,
             **kwargs):
    """
    Args:
    name: Full Name of the user,
    username: username (should not be already present),
    nationality: nationality,
    age: age

    Returns:
    user_id
    """
    if check_user(username):
        return None

    user = User()
    user.name = name
    user.username = username
    user.nationality = nationality
    user.age = age
    user.save()
    user_id = user.id

    return user_id
Beispiel #2
0
def add_user_by_object(user):
    if user.id is not None:
        if check_user(user.username) == False:
            new_user = User()
            new_user.id = user.id
            new_user.name = user.name
            new_user.username = user.username
            new_user.nationality = user.nationality
            new_user.age = user.age
            new_user.save()
    else:
        return None