diff options
Diffstat (limited to 'indoteknik_api/controllers/api_v1')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/category.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/indoteknik_api/controllers/api_v1/category.py b/indoteknik_api/controllers/api_v1/category.py index 3a83f6a1..ff1baf6b 100644 --- a/indoteknik_api/controllers/api_v1/category.py +++ b/indoteknik_api/controllers/api_v1/category.py @@ -56,12 +56,24 @@ class Category(controller.Controller): data.append(parent_data) return self.response(data) + @http.route(prefix + 'categories_homepage/ids', auth='public', methods=['GET', 'OPTIONS']) + def get_categories_homepage_count(self, **kw): + if not self.authenticate(): + return self.response(code=401, description='Unauthorized') + query = [('status', '=', 'tayang')] + categories = request.env['website.categories.homepage'].search_read(query, ['id']) + return self.response([x['id'] for x in categories]) + + @http.route(prefix + 'categories_homepage', auth='public', methods=['GET', 'OPTIONS']) def get_categories_homepage(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')] + id = kw.get('id') + if id: + query.append(('id', '=', id)) categories = request.env['website.categories.homepage'].search(query, order='sequence') data = [] for category in categories: |
