From 083e4ab620edc20534992d6dd8b891796ecb35ce Mon Sep 17 00:00:00 2001 From: stephanchrst Date: Tue, 3 Jan 2023 11:31:57 +0700 Subject: add window dynamic customer review --- indoteknik_api/controllers/api_v1/__init__.py | 1 + indoteknik_api/controllers/api_v1/customer.py | 28 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 indoteknik_api/controllers/api_v1/customer.py (limited to 'indoteknik_api/controllers/api_v1') diff --git a/indoteknik_api/controllers/api_v1/__init__.py b/indoteknik_api/controllers/api_v1/__init__.py index 5b4f38a0..2a93bcae 100644 --- a/indoteknik_api/controllers/api_v1/__init__.py +++ b/indoteknik_api/controllers/api_v1/__init__.py @@ -11,3 +11,4 @@ from . import sale_order from . import user from . import wishlist from . import brand_homepage +from . import customer diff --git a/indoteknik_api/controllers/api_v1/customer.py b/indoteknik_api/controllers/api_v1/customer.py new file mode 100644 index 00000000..58c93376 --- /dev/null +++ b/indoteknik_api/controllers/api_v1/customer.py @@ -0,0 +1,28 @@ +from .. import controller +from odoo import http +from odoo.http import request +import ast + + +class CustomerReview(controller.Controller): + prefix = '/api/v1/' + + @http.route(prefix + 'customer_review', auth='public', methods=['GET', 'OPTIONS']) + def get_customer_review(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') + query = [('status', '=', 'tayang')] + reviews = request.env['customer.review'].search(query, order='sequence') + data = [] + for review in reviews: + data.append({ + 'id': review.id, + 'sequence': review.sequence, + 'image': base_url + 'api/image/customer.review/image/' + str(review.id) if review.image else '', + 'customer_name': review.customer_name, + 'ulasan': review.ulasan, + 'name': review.name, + 'jabatan': review.jabatan + }) + return self.response(data) -- cgit v1.2.3