summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1
diff options
context:
space:
mode:
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
-rw-r--r--indoteknik_api/controllers/api_v1/banner.py3
-rw-r--r--indoteknik_api/controllers/api_v1/content.py31
2 files changed, 29 insertions, 5 deletions
diff --git a/indoteknik_api/controllers/api_v1/banner.py b/indoteknik_api/controllers/api_v1/banner.py
index 9a4a9ec7..1327a749 100644
--- a/indoteknik_api/controllers/api_v1/banner.py
+++ b/indoteknik_api/controllers/api_v1/banner.py
@@ -11,7 +11,6 @@ class Banner(controller.Controller):
if not self.authenticate():
return self.response(code=401, description='Unauthorized')
- base_url = request.env['ir.config_parameter'].get_param('web.base.url')
manufacture_id = kw.get('manufacture_id')
type = kw.get('type')
limit = int(kw.get('limit', 0))
@@ -32,7 +31,7 @@ class Banner(controller.Controller):
data.append({
'name': banner.x_name,
'url': banner.x_url_banner,
- 'image': base_url + 'api/image/x_banner.banner/x_banner_image/' + str(banner.id) if banner.x_banner_image else '',
+ 'image': request.env['ir.attachment'].api_image('x_banner.banner', 'x_banner_image', banner.id),
})
return self.response(data) \ No newline at end of file
diff --git a/indoteknik_api/controllers/api_v1/content.py b/indoteknik_api/controllers/api_v1/content.py
index 3e175dc4..2d788306 100644
--- a/indoteknik_api/controllers/api_v1/content.py
+++ b/indoteknik_api/controllers/api_v1/content.py
@@ -6,11 +6,36 @@ from odoo.http import request
class WebsiteContent(controller.Controller):
prefix = '/api/v1/'
- @http.route(prefix + 'banner/category', auth='public', methods=['GET', 'OPTIONS'])
- def get_banner_by_category(self, **kw):
+ @http.route(prefix + 'coupon_program', auth='public', methods=['GET', 'OPTIONS'])
+ def get_coupon_program(self, **kw):
if not self.authenticate():
return self.response(code=401, description='Unauthorized')
- base_url = request.env['ir.config_parameter'].get_param('web.base.url')
+
+ reward_type = str(kw.get('reward_type', ''))
+ limit = int(kw.get('limit', 0))
+ offset = int(kw.get('offset', 0))
+
+ query = [
+ ('x_studio_image_promo', '!=', ''),
+ ]
+ if reward_type:
+ query += [('reward_type', '=', reward_type)]
+
+ coupons = request.env['coupon.program'].search(query, limit=limit, offset=offset)
+ data = {
+ 'coupon_total': request.env['coupon.program'].search_count(query),
+ 'coupons': [request.env['coupon.program'].api_single_response(x) for x in coupons]
+ }
+ # print (data)
+ return self.response(data)
+
+
+
+ @http.route(prefix + 'banner/brand', auth='public', methods=['GET', 'OPTIONS'])
+ def get_banner_by_brand(self, **kw):
+ if not self.authenticate():
+ return self.response(code=401, description='Unauthorized')
+ # base_url = request.env['ir.config_parameter'].get_param('web.base.url')
category_id = int(kw.get('category_id'), 0)
query = [