[MOV] website_slides: move slide.embed model into its own file
As we are going to do some rework on the slide.embed feature, let's put the model into its own python file. Task-2654009 Part-of: odoo/odoo#77736
This commit is contained in:
@@ -5,6 +5,7 @@ from . import ir_http
|
||||
from . import gamification_challenge
|
||||
from . import slide_slide
|
||||
from . import slide_question
|
||||
from . import slide_embed
|
||||
from . import slide_channel
|
||||
from . import slide_channel_tag
|
||||
from . import slide_slide_resource
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from werkzeug import urls
|
||||
|
||||
from odoo import fields, models
|
||||
|
||||
|
||||
class EmbeddedSlide(models.Model):
|
||||
""" Embedding in third party websites. Track view count, generate statistics. """
|
||||
_name = 'slide.embed'
|
||||
_description = 'Embedded Slides View Counter'
|
||||
_rec_name = 'slide_id'
|
||||
|
||||
slide_id = fields.Many2one('slide.slide', string="Presentation", required=True, index=True)
|
||||
url = fields.Char('Third Party Website URL', required=True)
|
||||
count_views = fields.Integer('# Views', default=1)
|
||||
|
||||
def _add_embed_url(self, slide_id, url):
|
||||
baseurl = urls.url_parse(url).netloc
|
||||
if not baseurl:
|
||||
return 0
|
||||
embeds = self.search([('url', '=', baseurl), ('slide_id', '=', int(slide_id))], limit=1)
|
||||
if embeds:
|
||||
embeds.count_views += 1
|
||||
else:
|
||||
embeds = self.create({
|
||||
'slide_id': slide_id,
|
||||
'url': baseurl,
|
||||
})
|
||||
return embeds.count_views
|
||||
@@ -56,30 +56,6 @@ class SlidePartnerRelation(models.Model):
|
||||
('partner_id', 'in', self.partner_id.ids),
|
||||
])._recompute_completion()
|
||||
|
||||
class EmbeddedSlide(models.Model):
|
||||
""" Embedding in third party websites. Track view count, generate statistics. """
|
||||
_name = 'slide.embed'
|
||||
_description = 'Embedded Slides View Counter'
|
||||
_rec_name = 'slide_id'
|
||||
|
||||
slide_id = fields.Many2one('slide.slide', string="Presentation", required=True, index=True)
|
||||
url = fields.Char('Third Party Website URL', required=True)
|
||||
count_views = fields.Integer('# Views', default=1)
|
||||
|
||||
def _add_embed_url(self, slide_id, url):
|
||||
baseurl = urls.url_parse(url).netloc
|
||||
if not baseurl:
|
||||
return 0
|
||||
embeds = self.search([('url', '=', baseurl), ('slide_id', '=', int(slide_id))], limit=1)
|
||||
if embeds:
|
||||
embeds.count_views += 1
|
||||
else:
|
||||
embeds = self.create({
|
||||
'slide_id': slide_id,
|
||||
'url': baseurl,
|
||||
})
|
||||
return embeds.count_views
|
||||
|
||||
|
||||
class SlideTag(models.Model):
|
||||
""" Tag to search slides across channels. """
|
||||
|
||||
Reference in New Issue
Block a user