Ejemplo n.º 1
0
def get_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if Scope.admin in g.scopes or Scope.admin_customers in g.scopes or customer.customer in g.customers:
        return jsonify(status='ok', total=1, customer=customer.serialize)
    else:
        raise ApiError('not found', 404)
Ejemplo n.º 2
0
def get_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if customer:
        return jsonify(status='ok', total=1, customer=customer.serialize)
    else:
        raise ApiError('not found', 404)
Ejemplo n.º 3
0
def get_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if Scope.admin in g.scopes or Scope.admin_customers in g.scopes or customer.customer in g.customers:
        return jsonify(status='ok', total=1, customer=customer.serialize)
    else:
        raise ApiError('not found', 404)
Ejemplo n.º 4
0
def delete_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError("not found", 404)

    if customer.delete():
        return jsonify(status="ok")
    else:
        raise ApiError("failed to delete customer", 500)
Ejemplo n.º 5
0
def delete_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError("not found", 404)

    if customer.delete():
        return jsonify(status="ok")
    else:
        raise ApiError("failed to delete customer", 500)
Ejemplo n.º 6
0
def delete_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError('not found', 404)

    if customer.delete():
        return jsonify(status='ok')
    else:
        raise ApiError('failed to delete customer', 500)
Ejemplo n.º 7
0
def delete_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError('not found', 404)

    admin_audit_trail.send(current_app._get_current_object(), event='customer-deleted', message='', user=g.user,
                           customers=g.customers, scopes=g.scopes, resource_id=customer.id, type='customer', request=request)

    if customer.delete():
        return jsonify(status='ok')
    else:
        raise ApiError('failed to delete customer', 500)
Ejemplo n.º 8
0
def delete_customer(customer_id):
    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError('not found', 404)

    admin_audit_trail.send(current_app._get_current_object(), event='customer-deleted', message='', user=g.login,
                           customers=g.customers, scopes=g.scopes, resource_id=customer.id, type='customer', request=request)

    if customer.delete():
        return jsonify(status='ok')
    else:
        raise ApiError('failed to delete customer', 500)
Ejemplo n.º 9
0
def update_customer(customer_id):
    if not request.json:
        raise ApiError('nothing to change', 400)

    customer = Customer.find_by_id(customer_id)

    if not customer:
        raise ApiError('not found', 404)

    admin_audit_trail.send(current_app._get_current_object(),
                           event='customer-updated',
                           message='',
                           user=g.login,
                           customers=g.customers,
                           scopes=g.scopes,
                           resource_id=customer.id,
                           type='customer',
                           request=request)

    if customer.update(**request.json):
        return jsonify(status='ok')
    else:
        raise ApiError('failed to update customer', 500)