mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Handled default value in post for specific tier content visibility (#14121)
refs https://github.com/TryGhost/Team/issues/1071 Default visibility for a post when set to specific tiers needs special handling as data for specific tiers is stored as an array of tiers on a pivot table. This change handles the default visibility for a new post when set to specific tiers to generate the right default values in model.
This commit is contained in:
parent
3cebde7279
commit
f3119cbf77
1 changed files with 15 additions and 3 deletions
|
@ -54,9 +54,20 @@ Post = ghostBookshelf.Model.extend({
|
|||
*/
|
||||
defaults: function defaults() {
|
||||
let visibility = 'public';
|
||||
|
||||
if (settingsCache.get('default_content_visibility')) {
|
||||
visibility = settingsCache.get('default_content_visibility');
|
||||
let tiers = [];
|
||||
const defaultContentVisibility = settingsCache.get('default_content_visibility');
|
||||
if (defaultContentVisibility) {
|
||||
if (defaultContentVisibility === 'tiers') {
|
||||
const tiersData = settingsCache.get('default_content_visibility_tiers') || [];
|
||||
visibility = 'tiers',
|
||||
tiers = tiersData.map((tierId) => {
|
||||
return {
|
||||
id: tierId
|
||||
};
|
||||
});
|
||||
} else if (defaultContentVisibility !== 'tiers') {
|
||||
visibility = settingsCache.get('default_content_visibility');
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -64,6 +75,7 @@ Post = ghostBookshelf.Model.extend({
|
|||
status: 'draft',
|
||||
featured: false,
|
||||
type: 'post',
|
||||
tiers,
|
||||
visibility: visibility,
|
||||
email_recipient_filter: 'none'
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue