summaryrefslogtreecommitdiff
path: root/indoteknik_api/controllers/api_v1/content.py
diff options
context:
space:
mode:
authorstephanchrst <stephanchrst@gmail.com>2023-01-26 10:34:05 +0700
committerstephanchrst <stephanchrst@gmail.com>2023-01-26 10:34:05 +0700
commitaed1817bac8a608bfd630acc8d5d406f13732387 (patch)
tree7488b0f1352ca8b276871db446c6673cf0626ed3 /indoteknik_api/controllers/api_v1/content.py
parent9df53ac2b48ee5f6285715f642b341dff93ad295 (diff)
add rest coupon program
Diffstat (limited to 'indoteknik_api/controllers/api_v1/content.py')
-rw-r--r--indoteknik_api/controllers/api_v1/content.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/indoteknik_api/controllers/api_v1/content.py b/indoteknik_api/controllers/api_v1/content.py
index 3e175dc4..c5b6fd71 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 + 'coupon_program', auth='public', methods=['GET', 'OPTIONS'])
+ def get_coupon_program(self, **kw):
+ if not self.authenticate():
+ return self.response(code=401, description='Unauthorized')
+
+ 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/category', auth='public', methods=['GET', 'OPTIONS'])
def get_banner_by_category(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')
+ # base_url = request.env['ir.config_parameter'].get_param('web.base.url')
category_id = int(kw.get('category_id'), 0)
query = [