コード例 #1
0
def api_day_subscriptions(period, day, customer_id):

    page = request.args.get("page")
    per_page = request.args.get("per_page")

    if page is None:
        page = 1
    if per_page is None:
        per_page = 10

    data, prev_page, next_page = subscriptionServices.get_some_pagination(
        period=period,
        day=day,
        customer_id=customer_id,
        page=int(page),
        per_page=int(per_page))

    return jsonify(
        Pagination.get_paginated_db(
            data,
            '/api/subscriptions/period/' + period + '/date/' + day +
            '/customers/' + str(customer_id),
            page=request.args.get('page', page),
            per_page=request.args.get('per_page', per_page),
            prev_page=prev_page,
            next_page=next_page))
コード例 #2
0
def api_orders_by_seller(seller_id):
  page = request.args.get("page")
  per_page = request.args.get("per_page")

  if page is None:
    page = 1
  if per_page is None:
    per_page=10

  data, prev_page, next_page = orderServices.get_all_by_seller_pagination(seller_id, page=int(page), per_page=int(per_page))
  return jsonify(Pagination.get_paginated_db(
    data, '/api/orders/sellers/'+str(seller_id),
    page=request.args.get('page', page),
    per_page=request.args.get('per_page', per_page),
    prev_page=prev_page, next_page=next_page))
コード例 #3
0
def api_shipments_by_customer(customer_id):
    page = request.args.get("page")
    per_page = request.args.get("per_page")

    if page is None:
        page = 1
    if per_page is None:
        per_page=10
    
    data, prev_page, next_page = shipmentServices.get_all_by_customer_pagination(customer_id, page=int(page), per_page=int(per_page))
    
    return jsonify(Pagination.get_paginated_db(
        data, '/api/shipments/customers/'+str(customer_id),
        page=request.args.get('page', page),
        per_page=request.args.get('per_page', per_page),
        prev_page=prev_page, next_page=next_page ))
コード例 #4
0
def api_day_shipments_no_canceled_no_paid(period, day, customer_id):
    page = request.args.get("page")
    per_page = request.args.get("per_page")

    if page is None:
        page = 1
    if per_page is None:
        per_page=30
    
    data, prev_page, next_page = shipmentServices.get_some_pagination(
        period=period, day=day, customer_id=customer_id, page=int(page), per_page=int(per_page), nocanceled=True, nopaid=True)

    return jsonify(Pagination.get_paginated_db(
        data, '/api/shipments/period/'+period+'/date/'+day+'/customers/'+str(customer_id)+'/nocanceled/nopaid',
        page=request.args.get('page', page),
        per_page=request.args.get('per_page', per_page),
        prev_page=prev_page, next_page=next_page))
コード例 #5
0
def api_day_shipments(period, day):
    page = request.args.get("page")
    per_page = request.args.get("per_page")

    if page is None:
        page = 1
    if per_page is None:
        per_page=40
    
    user_id = current_user.get_id()
    user = userServices.get_by_username(user_id)
    
    data, prev_page, next_page = shipmentServices.get_some_pagination(period=period, day=day, customer_id=user.account_id, page=int(page), per_page=int(per_page))

    return jsonify(Pagination.get_paginated_db(
        data, '/api/customer/shipments/period/'+period+'/date/'+day,
        page=request.args.get('page', page),
        per_page=request.args.get('per_page', per_page),
        prev_page=prev_page, next_page=next_page))
コード例 #6
0
def api_customers_cities(city):
    page = request.args.get("page")
    per_page = request.args.get("per_page")

    if page is None:
        page = 1
    if per_page is None:
        per_page = 10

    data, prev_page, next_page = customerServices.get_all_by_city_pagination(
        city, page=int(page), per_page=int(per_page))

    return jsonify(
        Pagination.get_paginated_db(data,
                                    '/api/customers/cities/' + city,
                                    page=request.args.get('page', page),
                                    per_page=request.args.get(
                                        'per_page', per_page),
                                    prev_page=prev_page,
                                    next_page=next_page))
コード例 #7
0
def api_products_by_product_id(seller_id, product_id):
    page = request.args.get("page")
    per_page = request.args.get("per_page")

    if page is None:
        page = 1
    if per_page is None:
        per_page=10

    product = productServices.get_one(int(product_id))
    data = [product]
    prev_page = None
    next_page = None
    
   
    return jsonify(Pagination.get_paginated_db(
        data, '/api/products/sellers/'+str(seller_id),
        page=request.args.get('page', page),
        per_page=request.args.get('per_page', per_page),
        prev_page=prev_page, next_page=next_page))
コード例 #8
0
def api_sellers():
    page = request.args.get("page")
    per_page = request.args.get("per_page")

    if page is None:
        page = 1
    if per_page is None:
        per_page = 10

    data, prev_page, next_page = sellerServices.optim_get_all_pagination(
        page=int(page), per_page=int(per_page))

    return jsonify(
        Pagination.get_paginated_db(data,
                                    '/api/sellers/',
                                    page=request.args.get('page', page),
                                    per_page=request.args.get(
                                        'per_page', per_page),
                                    prev_page=prev_page,
                                    next_page=next_page))
コード例 #9
0
ファイル: user_controller.py プロジェクト: pigalon/lecopainPi
def api_users_by_role(role_id):
    page = request.args.get("page")
    per_page = request.args.get("per_page")

    if page is None:
        page = 1
    if per_page is None:
        per_page = 10

    data, prev_page, next_page = userServices.optim_get_all_pagination(
        role_id=int(role_id), page=int(page), per_page=int(per_page))

    return jsonify(
        Pagination.get_paginated_db(data,
                                    '/api/users/roles/' + role_id,
                                    page=request.args.get('page', page),
                                    per_page=request.args.get(
                                        'per_page', per_page),
                                    prev_page=prev_page,
                                    next_page=next_page))
コード例 #10
0
def api_customers_customer_id(city, customer_id):
    page = request.args.get("page")
    per_page = request.args.get("per_page")

    if page is None:
        page = 1
    if per_page is None:
        per_page = 10

    customer = customerServices.read_one(customer_id)
    data = [customer]
    prev_page = None
    next_page = None

    return jsonify(
        Pagination.get_paginated_db(data,
                                    '/api/customers/cities/' + city,
                                    page=request.args.get('page', page),
                                    per_page=request.args.get(
                                        'per_page', per_page),
                                    prev_page=prev_page,
                                    next_page=next_page))
コード例 #11
0
def api_products_by_seller():
    page = request.args.get("page")
    per_page = request.args.get("per_page")

    user_id = current_user.get_id()
    user = userService.get_by_username(user_id)
    seller_id = user.account_id

    if page is None:
        page = 1
    if per_page is None:
        per_page = 30

    data, prev_page, next_page = productServices.get_all_by_seller_pagination(
        seller_id=seller_id, page=int(page), per_page=int(per_page))

    return jsonify(
        Pagination.get_paginated_db(data,
                                    '/seller/api/products',
                                    page=request.args.get('page', page),
                                    per_page=request.args.get(
                                        'per_page', per_page),
                                    prev_page=prev_page,
                                    next_page=next_page))