From 5e4f37a1f88b549e02273edb93611e47abdecd61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Warnon?= Date: Wed, 7 Aug 2019 06:01:35 +0000 Subject: [PATCH] [REF] website_slides: remove index_content field from slide.slide The 'index_content' field was only filled when uploading from the frontend. That would lead to inconsistent results when creating/updating 'presentation' slides from the slide.slide form view. The field was also not cleaned if the slide content changed. As it's usage was not very clear (only on a 'search', and not very intuitive), we simply removed the field. --- addons/website_slides/controllers/main.py | 3 +-- addons/website_slides/models/slide_slide.py | 8 ------ .../static/src/js/slides_upload.js | 27 ------------------- .../static/src/xml/website_slides_upload.xml | 1 - .../views/website_slides_templates_lesson.xml | 10 ------- 5 files changed, 1 insertion(+), 48 deletions(-) diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index d33867331ab..a3cf6d99c78 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -359,7 +359,6 @@ class WebsiteSlides(WebsiteProfile): '|', '|', '|', ('name', 'ilike', search), ('description', 'ilike', search), - ('index_content', 'ilike', search), ('html_content', 'ilike', search)] pager_args['search'] = search else: @@ -842,7 +841,7 @@ class WebsiteSlides(WebsiteProfile): def _get_valid_slide_post_values(self): return ['name', 'url', 'tag_ids', 'slide_type', 'channel_id', 'is_preview', - 'mime_type', 'datas', 'description', 'image_1920', 'index_content', 'is_published'] + 'mime_type', 'datas', 'description', 'image_1920', 'is_published'] @http.route(['/slides/tag/search_read'], type='json', auth='user', methods=['POST'], website=True) def slide_tag_search_read(self, fields, domain): diff --git a/addons/website_slides/models/slide_slide.py b/addons/website_slides/models/slide_slide.py index a1b99fe90f7..d4ab74afc37 100644 --- a/addons/website_slides/models/slide_slide.py +++ b/addons/website_slides/models/slide_slide.py @@ -134,7 +134,6 @@ class Slide(models.Model): string='Type', required=True, default='document', help="The document type will be set automatically based on the document URL and properties (e.g. height and width for presentation and document).") - index_content = fields.Text('Transcript') datas = fields.Binary('Content', attachment=True) url = fields.Char('Document URL', help="Youtube or Google Document URL") document_id = fields.Char('Document ID', help="Youtube or Google Document ID") @@ -353,8 +352,6 @@ class Slide(models.Model): # 'website_published' is handled by mixin values['date_published'] = False - if not values.get('index_content'): - values['index_content'] = values.get('description') if values.get('slide_type') == 'infographic' and not values.get('image_1920'): values['image_1920'] = values['datas'] if values.get('is_category'): @@ -756,11 +753,6 @@ class Slide(models.Model): values['slide_type'] = get_slide_type(values) if 'exportLinks' in google_values: values['datas'] = self._fetch_data(google_values['exportLinks']['application/pdf'], params, 'pdf')['values'] - # Content indexing - if google_values['exportLinks'].get('text/plain'): - values['index_content'] = self._fetch_data(google_values['exportLinks']['text/plain'], params)['values'] - elif google_values['exportLinks'].get('text/csv'): - values['index_content'] = self._fetch_data(google_values['exportLinks']['text/csv'], params)['values'] elif google_values['mimeType'] == 'application/pdf': # TODO: Google Drive PDF document doesn't provide plain text transcript values['datas'] = self._fetch_data(google_values['webContentLink'], {}, 'pdf')['values'] diff --git a/addons/website_slides/static/src/js/slides_upload.js b/addons/website_slides/static/src/js/slides_upload.js index 23e6411f512..ec3958e8d0e 100644 --- a/addons/website_slides/static/src/js/slides_upload.js +++ b/addons/website_slides/static/src/js/slides_upload.js @@ -129,7 +129,6 @@ var SlideUploadDialog = Dialog.extend({ 'name': this._formGetFieldValue('name'), 'url': this._formGetFieldValue('url'), 'description': this._formGetFieldValue('description'), - 'index_content': this._formGetFieldValue('index_content'), 'duration': this._formGetFieldValue('duration'), 'is_published': forcePublished, }, this._getSelect2DropdownValues()); // add tags and category @@ -463,32 +462,6 @@ var SlideUploadDialog = Dialog.extend({ loaded = true; }); }); - var maxPages = pdf.pdfInfo.numPages; - var page, j; - self.index_content = ''; - for (j = 1; j <= maxPages; j += 1) { - page = pdf.getPage(j); - page.then(function (pageObj) { - var pageNumber = pageObj.pageIndex + 1; - pageObj.getTextContent().then(function (data) { - var pageContent = ''; - _.each(data.items, function (obj) { - pageContent = pageContent + obj.str + ' '; - }); - // page_content may contain null characters - pageContent = pageContent.replace(/\0/g, ''); - var indexContent = self._formGetFieldValue('index_content') + pageNumber + '. ' + pageContent + '\n'; - self._formSetFieldValue('index_content', indexContent); - - if (maxPages === pageNumber) { - if (loaded) { - self.set('can_submit_form', false); - } - loaded = true; - } - }); - }); - } }); }; } diff --git a/addons/website_slides/static/src/xml/website_slides_upload.xml b/addons/website_slides/static/src/xml/website_slides_upload.xml index e5d5e0d839f..877e8b9d967 100644 --- a/addons/website_slides/static/src/xml/website_slides_upload.xml +++ b/addons/website_slides/static/src/xml/website_slides_upload.xml @@ -89,7 +89,6 @@ - diff --git a/addons/website_slides/views/website_slides_templates_lesson.xml b/addons/website_slides/views/website_slides_templates_lesson.xml index d049a333f3f..9f567b5cc29 100644 --- a/addons/website_slides/views/website_slides_templates_lesson.xml +++ b/addons/website_slides/views/website_slides_templates_lesson.xml @@ -255,11 +255,6 @@ Comments () -