diff options
| author | stephanchrst <stephanchrst@gmail.com> | 2023-01-03 11:31:57 +0700 |
|---|---|---|
| committer | stephanchrst <stephanchrst@gmail.com> | 2023-01-03 11:31:57 +0700 |
| commit | 083e4ab620edc20534992d6dd8b891796ecb35ce (patch) | |
| tree | 811afc8b68f921c0f60ec8c73abae52fb0e5121d /indoteknik_api/controllers/api_v1 | |
| parent | fbea3ab095059a101d32c2f5e4f5b0f309705d28 (diff) | |
add window dynamic customer review
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/__init__.py | 1 | ||||
| -rw-r--r-- | indoteknik_api/controllers/api_v1/customer.py | 28 |
2 files changed, 29 insertions, 0 deletions
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) |
