diff options
| author | IT Fixcomart <it@fixcomart.co.id> | 2023-01-23 09:20:18 +0000 |
|---|---|---|
| committer | IT Fixcomart <it@fixcomart.co.id> | 2023-01-23 09:20:18 +0000 |
| commit | da5f5134f56b2ccf1c1de16c3f7616ab3719f3ea (patch) | |
| tree | bc1bcb4fb00f2659be81810d528a9cf2cc6ce20d /indoteknik_api/controllers/api_v1/content.py | |
| parent | e52cf84fd2284330412162b44066f29bd382f590 (diff) | |
| parent | 8af5ee591aabc2d5d946c0eece93a5caab989975 (diff) | |
Merged in release (pull request #27)
Release
Diffstat (limited to 'indoteknik_api/controllers/api_v1/content.py')
| -rw-r--r-- | indoteknik_api/controllers/api_v1/content.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/indoteknik_api/controllers/api_v1/content.py b/indoteknik_api/controllers/api_v1/content.py index 3d5b15e5..3d4e443a 100644 --- a/indoteknik_api/controllers/api_v1/content.py +++ b/indoteknik_api/controllers/api_v1/content.py @@ -6,6 +6,26 @@ from odoo.http import request class WebsiteContent(controller.Controller): prefix = '/api/v1/' + @http.route(prefix + 'product_ads', auth='public', methods=['GET', 'OPTIONS']) + def get_product_ads(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 = [ + ('page', '=', 'product'), + ('status', '=', 'tayang') + ] + ads = request.env['website.ads'].search(query, order='sequence') + data = [] + for ad in ads: + data.append({ + 'id': ad.id, + 'name': ad.name, + 'image': base_url + 'api/image/website.ads/image/' + str(ad.id) if ad.image else '', + 'url': ad.url, + }) + return self.response(data) + @http.route(prefix + 'video_content', auth='public', methods=['GET', 'OPTIONS']) def get_video_content(self, **kw): if not self.authenticate(): |
