Exemple #1
0
def create (ctx, name, company, email, position):
    """Creates a new client"""

    client = ClientModel(name, company, email, position)
    client_services = ClientServices(ctx.obj["file_name"])

    client_services.create_client(client)
def delete(ctx, client_uid):
    """Delete a client"""
    client_service = ClientServices(ctx.obj['clients_table'])
    client_list = client_service.list_clients()

    client = [client for client in client_list if client['uid'] == client_uid]

    if client:
        client_service._delete_client(Client(**client[0]))
        click.echo('Remove it')
    else:
        click.echo('Client not found')
Exemple #3
0
def update(ctx, client_uid):
    """Update a client"""
    client_service = ClientServices(ctx.obj['clients_table'])
    client_list = client_service.list_clients()
    client = [client for client in client_list if client['uid'] == client_uid]

    if client:
        client = _update_client_flow(Client(**client[0]))
        client_service.update_client(client)

        click.echo('Clien updated')
    else:
        click.echo('Client not found')
Exemple #4
0
def list(ctx):
    """ List clients"""
    client_services = ClientServices(ctx.obj['clients_table'])
    clients_list = client_services.list_clients()
    click.echo('uuid | name | age | company | job')
    click.echo("*" * 70)
    for client in clients_list:
        click.echo('{uid} | {name} | {age} | {company} | {job}'.format(
            uid=client['uid'],
            name=client['name'],
            age=client['age'],
            company=client['company'],
            job=client['job']))
Exemple #5
0
def delete (ctx, client_uid):
    """Deletes a client"""
    client_services = ClientServices(ctx.obj["file_name"])

    clients_list = client_services.list_clients()

    client = [client for client in clients_list if client["uid"] == client_uid]

    if client:
        client = ClientModel(**client[0])
        client_services.delete_client(client)
        click.echo("Client deleted!")
    else:
        click.echo("Client not found!")       
Exemple #6
0
def delete(ctx, client_uid):
    """ Delete a client"""
    client_services = ClientServices(ctx.obj['clients_table'])

    clients_list = client_services.list_clients()

    client = [client for client in clients_list if client['uid'] == client_uid]

    if client:
        client = ClientModel(**client[0])
        client_services.delete_client(client)
        click.echo('Client deleted')
    else:
        click.echo('Client not fount')
Exemple #7
0
def update (ctx, client_uid):
    """Updates a client"""
    client_services = ClientServices(ctx.obj["file_name"])

    clients_list = client_services.list_clients()

    client = [client for client in clients_list if client["uid"] == client_uid]
    
    if client:
        client = _update_client_flow(ClientModel(**client[0]))
        client_services.update_client(client)

        click.echo("Client updated successfuly!")
    else:
        click.echo("Client not found!")
Exemple #8
0
def list(ctx):
    """List all clients"""
    client_service = ClientServices(ctx.obj['clients_table'])
    clients_list = client_service.list_clients()
    click.echo(' ID  |  NAME  |  COMPANY  |  EMAIL  |  POSITION')
    click.echo('*' * 100)

    for client in clients_list:
        click.echo(
            '{uid}  |  {name}  |  {company}  |  {email}  |  {position}'.format(
                uid=client['uid'],
                name=client['name'],
                company=client['company'],
                email=client['email'],
                position=client['position']))
def search(ctx, client_uid):
    """Search a client """
    client_service = ClientServices(ctx.obj['clients_table'])
    client_found = client_service.search_client(client_uid)

    click.echo('  ID  |  NAME  |  COMPANY  |  EMAIL  |  POSITION')
    click.echo('*'*50)

    for client in client_found:
        print('{uid}  |  {name}  |  {company}  |  {email}  |  {position}'.format(
            uid = client['uid'],
            name = client['name'],
            company = client['company'],
            email = client['email'],
            position = client['position']
        ))
Exemple #10
0
def list (ctx):
    """Lists all clients"""
    
    client_services = ClientServices(ctx.obj["file_name"])

    clients_list = client_services.list_clients()

    click.echo((" " * 34 ) + "ID  |  NAME  |  COMPANY  |  EMAIL  |  POSITION")
    click.echo("_" * 100)

    for client in clients_list:
        click.echo("{uid}  | {name}  |  {company}  |  {email}  | {position}".format(
                uid = client["uid"],
                name = client["name"],
                company = client["company"],
                email = client["email"],
                position = client["position"]))
Exemple #11
0
def create(ctx, name, company, email, position):
    """Creates a new client"""
    client = Client(name, company, email, position)
    client_service = ClientServices(ctx.obj['clients_table'])

    client_service.create_client(client)
Exemple #12
0
def create(ctx, name, age, company, job):
    """ Create new clients """
    client = ClientModel(name, age, company, job)
    client_services = ClientServices(ctx.obj['clients_table'])
    client_services.create_client(client)