mirror of
https://github.com/TryGhost/Ghost.git
synced 2023-12-13 21:00:40 +01:00
Updated Integration model to use generateSlug (#10009)
no-issue This ensures that slugs are stripped of illegal characters, and that we do not create duplicates.
This commit is contained in:
parent
9fd9186557
commit
3a70cdb2b6
1 changed files with 11 additions and 0 deletions
|
@ -9,6 +9,17 @@ const Integration = ghostBookshelf.Model.extend({
|
|||
api_keys: 'api_keys'
|
||||
},
|
||||
|
||||
onSaving(newIntegration, attr, options) {
|
||||
if (this.hasChanged('slug') || !this.get('slug')) {
|
||||
// Pass the new slug through the generator to strip illegal characters, detect duplicates
|
||||
return ghostBookshelf.Model.generateSlug(Integration, this.get('slug') || this.get('name'),
|
||||
{transacting: options.transacting})
|
||||
.then((slug) => {
|
||||
this.set({slug});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
permittedAttributes(...args) {
|
||||
return ghostBookshelf.Model.prototype.permittedAttributes.apply(this, args).concat(this.relationships);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue