[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.
This commit is contained in:
Aurélien Warnon
2019-08-12 15:40:36 +00:00
committed by Thibault Delavallée
parent 5269d8c27f
commit 5e4f37a1f8
5 changed files with 1 additions and 48 deletions
+1 -2
View File
@@ -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):
@@ -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']
@@ -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;
}
});
});
}
});
};
}
@@ -89,7 +89,6 @@
<label for="upload" class="col-form-label">PDF or Image File</label>
</h5>
<input id="upload" name="file" class="form-control" accept="image/*,application/pdf" type="file" required="required"/>
<input id="index_content" name="index_content" type="hidden"/>
</li>
</ul>
</div>
@@ -255,11 +255,6 @@
<i class="fa fa-comments-o"></i> Comments (<span t-esc="slide.comments_count"/>)
</a>
</li>
<li class="nav-item" t-if="slide.index_content">
<a href="#transcript" aria-controls="transcript" class="nav-link" role="tab" data-toggle="tab">
<i class="fa fa-align-justify"></i> Transcript
</a>
</li>
<li class="nav-item">
<a href="#statistic" aria-controls="statistic" class="nav-link" role="tab" data-toggle="tab">
<i class="fa fa-bar-chart"></i> Statistics
@@ -282,11 +277,6 @@
<t t-set="display_rating" t-value="False"/>
</t>
</div>
<div role="tabpanel" class="tab-pane fade oe_slides_transcript" id="transcript" t-if="slide.index_content">
<t t-foreach="slide.index_content.split('\n')" t-as="line">
<p t-esc="line"></p>
</t>
</div>
<div role="tabpanel" class="tab-pane fade" id="statistic" t-att-slide-url="slide.website_url">
<div class="row">
<div class="col-12 col-md">