[IMP] website_slides: remove unique slide name constraint within channel
Having a unique constraint for a slide name in a channel look strange. It force an RPC call to check this when uploading a slide, making the process a little bit slow. Morevover, name is a translatable field on slide.slide model, so the constraint can not be fully respected. To simplify the model, we decided to remove this. Task-1938643
This commit is contained in:
@@ -101,10 +101,6 @@ class Slide(models.Model):
|
||||
'channel_id', 'description', 'tag_ids', 'write_date', 'create_date',
|
||||
'website_published', 'website_url', 'website_meta_title', 'website_meta_description', 'website_meta_keywords', 'website_meta_og_img']
|
||||
|
||||
_sql_constraints = [
|
||||
('name_uniq', 'UNIQUE(channel_id, name)', 'The slide name must be unique within a channel')
|
||||
]
|
||||
|
||||
# description
|
||||
name = fields.Char('Title', required=True, translate=True)
|
||||
active = fields.Boolean(default=True)
|
||||
|
||||
@@ -51,17 +51,6 @@ var SlideDialog = Widget.extend({
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {string} file_name
|
||||
*/
|
||||
_checkUniqueSlide: function (fileName) {
|
||||
return this._rpc({
|
||||
model: 'slide.slide',
|
||||
method: 'search_count',
|
||||
args: [[['channel_id', '=', self.channelId], ['name', '=', fileName]]],
|
||||
});
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
@@ -405,13 +394,7 @@ var SlideDialog = Widget.extend({
|
||||
|
||||
var input = file.name;
|
||||
var inputVal = input.substr(0, input.lastIndexOf('.')) || input;
|
||||
this._checkUniqueSlide(inputVal).then(function (exist) {
|
||||
if (exist) {
|
||||
var message = _t("Channel contains the given title, please change before Save or Publish.");
|
||||
self._displayAlert(message);
|
||||
}
|
||||
self.$('#name').val(inputVal);
|
||||
});
|
||||
this.$('#name').val(inputVal);
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
|
||||
Reference in New Issue
Block a user