diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-07-22 16:51:17 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-07-22 16:51:17 +0700 |
| commit | 53430e0e6909592d577cb8041a87da5ad20c494e (patch) | |
| tree | 6458792d7edf721d11b4b46dcb0f1cdb86722f0f /indoteknik_api/controllers/api_v1 | |
| parent | 96b76106958d1743a99b11600cc99c7abaadbbb1 (diff) | |
<iman> add api categories_,management & delete sync to solr
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/category_management.py | 42 |
2 files changed, 43 insertions, 0 deletions
diff --git a/indoteknik_api/controllers/api_v1/__init__.py b/indoteknik_api/controllers/api_v1/__init__.py index 36fcbd53..5952a929 100644 --- a/indoteknik_api/controllers/api_v1/__init__.py +++ b/indoteknik_api/controllers/api_v1/__init__.py @@ -20,6 +20,7 @@ from . import sub_district from . import user from . import wishlist from . import brand_homepage +from . import category_management from . import customer from . import content from . import midtrans diff --git a/indoteknik_api/controllers/api_v1/category_management.py b/indoteknik_api/controllers/api_v1/category_management.py new file mode 100644 index 00000000..3c53960a --- /dev/null +++ b/indoteknik_api/controllers/api_v1/category_management.py @@ -0,0 +1,42 @@ +from odoo import http +from odoo.http import request +from .. import controller + +class CategoryManagement(controller.Controller): + prefix = '/api/v1/' + + @http.route(prefix + 'categories_management', auth='public', methods=['GET', 'OPTIONS'], csrf=False) + @controller.Controller.must_authorized() + def get_categories_management(self, **kw): + base_url = request.env['ir.config_parameter'].sudo().get_param('web.base.url') + + query = [('status', '=', 'tayang')] + + categories = request.env['website.categories.management'].search(query, order='sequence') + data = [] + for category in categories: + category_id2_data = [] + for x in category.category_id2: + child_data = [ + {'id_level_3': child.id, 'name': child.name, + 'image': request.env['ir.attachment'].api_image('product.public.category', 'image_1920', child.id)} + for child in x.child_frontend_id2 + ] + category_id2_data.append({ + 'id_level_2': x.id, + 'name': x.name, + 'image': request.env['ir.attachment'].api_image('product.public.category', 'image_1920', x.id), + 'child_frontend_id_i': child_data + }) + + data.append({ + 'id': category.id, + 'sequence': category.sequence, + 'category_id_i': category.category_id.id, + 'name': category.category_id.name, + 'image': request.env['ir.attachment'].api_image('product.public.category', 'image_1920', category.category_id.id), + 'categories': category_id2_data, + }) + return self.response(data, headers=[('Cache-Control', 'max-age=3600, public')]) + + |
