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')
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')
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']))
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!")
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')
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!")
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 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"]))