summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-10-16 11:19:07 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-10-16 11:19:07 +0700
commit34baf6dc9d7031fdfa196446ef4274fff03d0abc (patch)
treef8e4fc3bf65e280df9c0b8e80982f0f9828c162c /indoteknik_api/controllers/api_v1
parenteefe129e31b112d80038fc3aecf2aee4c4e10108 (diff)
Fix cart API
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
-rw-r--r--indoteknik_api/controllers/api_v1/cart.py7
-rw-r--r--indoteknik_api/controllers/api_v1/category.py2
-rw-r--r--indoteknik_api/controllers/api_v1/product.py2
3 files changed, 6 insertions, 5 deletions
diff --git a/indoteknik_api/controllers/api_v1/cart.py b/indoteknik_api/controllers/api_v1/cart.py
index 88fa9f88..8ef2c1c1 100644
--- a/indoteknik_api/controllers/api_v1/cart.py
+++ b/indoteknik_api/controllers/api_v1/cart.py
@@ -14,8 +14,9 @@ class Cart(controller.Controller):
user_id = int(user_id)
limit = int(kw.get('limit', 0))
offset = int(kw.get('offset', 0))
- query = [('user_id', '=', user_id), ('source', '=', 'add_to_cart')]
+ query = [('user_id', '=', user_id)]
carts = user_cart.search(query, limit=limit, offset=offset, order='create_date desc')
+ carts.write({'source': 'add_to_cart'})
data = {
'product_total': user_cart.search_count(query),
'products': carts.with_context(price_for="web").get_products()
@@ -26,7 +27,7 @@ class Cart(controller.Controller):
@controller.Controller.must_authorized()
def get_cart_count_by_user_id(self, user_id, **kw):
user_id = int(user_id)
- query = [('user_id', '=', user_id), ('source', '=', 'add_to_cart')]
+ query = [('user_id', '=', user_id)]
carts = request.env['website.user.cart'].search_count(query)
return self.response(carts)
@@ -77,7 +78,7 @@ class Cart(controller.Controller):
data_to_update['source'] = source
result = {}
- if cart and source in (None, 'add_to_cart'):
+ if cart:
# Update existing cart entry
cart.write(data_to_update)
result['id'] = cart.id
diff --git a/indoteknik_api/controllers/api_v1/category.py b/indoteknik_api/controllers/api_v1/category.py
index efa6b033..44a60bc9 100644
--- a/indoteknik_api/controllers/api_v1/category.py
+++ b/indoteknik_api/controllers/api_v1/category.py
@@ -135,4 +135,4 @@ class Category(controller.Controller):
category = category.parent_frontend_id
categories.reverse()
- return self.response(categories) \ No newline at end of file
+ return self.response(categories, headers=[('Cache-Control', 'max-age=3600, public')]) \ No newline at end of file
diff --git a/indoteknik_api/controllers/api_v1/product.py b/indoteknik_api/controllers/api_v1/product.py
index 0c8a286b..1b698f26 100644
--- a/indoteknik_api/controllers/api_v1/product.py
+++ b/indoteknik_api/controllers/api_v1/product.py
@@ -32,7 +32,7 @@ class Product(controller.Controller):
category = category.parent_frontend_id
categories.reverse()
- return self.response(categories)
+ return self.response(categories, headers=[('Cache-Control', 'max-age=3600, public')])
@http.route(prefix + 'product_variant/<id>/stock', auth='public', methods=['GET', 'OPTIONS'])
@controller.Controller.must_authorized()