Пример #1
0
def delete_client(client_id):
    client = ClientService.remove(client_id)

    if client == None:
        abort(404)

    client_schema = ClientSchema()
    return client_schema.jsonify(client)
Пример #2
0
def update_partial_client(client_id):
    username = request.json['username']

    if ClientService.get_by_username(username):
        return jsonify({'error': 'This username already exists!'})

    client = ClientService.update_username(client_id, username)

    if client == None:
        abort(404)

    client_schema = ClientSchema()
    return client_schema.jsonify(client)
Пример #3
0
def create_client():
    username = request.json['username']
    email = request.json['email']

    if ClientService.get_by_username(username):
        return jsonify({'error': 'This username already exists!'})

    if ClientService.get_by_email(email):
        return jsonify({'error': 'This email already exists!'})

    client = ClientService.add(username, email)

    client_schema = ClientSchema()
    return client_schema.jsonify(client)
Пример #4
0
def pag_clients(page_num):

    clients = ClientService.paginate(per_page=20, page=page_num).items

    clients_schema = ClientSchema(many=True)
    return clients_schema.jsonify(clients)
Пример #5
0
def get_client(client_id):
    client = ClientService.get_by_id(client_id)
    if client == None:
        abort(404)
    client_schema = ClientSchema()
    return client_schema.jsonify(client)
Пример #6
0
def get_clients():
    clients = ClientService.get_all()
    clients_schema = ClientSchema(many=True)
    return clients_schema.jsonify(clients)