from .. import controller from odoo import http from odoo.http import request class WebsiteContent(controller.Controller): prefix = '/api/v1/' @http.route(prefix + 'video_content', auth='public', methods=['GET', 'OPTIONS']) def get_video_content(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'), ('slide_type', '=', 'video')] videos = request.env['website.content'].search(query, order='sequence') data = [] for video in videos: data.append({ 'id': video.id, 'sequence': video.sequence, 'slide_type': video.slide_type, 'name': video.name, 'url': video.url, 'channel_id': video.channel_id, 'channel_name': video.channel_id.name }) return self.response(data)