mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Handled visibility filter for posts
refs https://github.com/TryGhost/Team/issues/849 Multiple products alpha feature brings back segmented post access using products. The new visibility filter based on segments is returned in a separate `visibility_filter` property on post/page API
This commit is contained in:
parent
72b2679505
commit
6feb14b839
3 changed files with 18 additions and 1 deletions
|
@ -93,6 +93,7 @@ export default Model.extend(Comparable, ValidationEngine, {
|
||||||
emailSubject: attr('string'),
|
emailSubject: attr('string'),
|
||||||
html: attr('string'),
|
html: attr('string'),
|
||||||
visibility: attr('string'),
|
visibility: attr('string'),
|
||||||
|
visibilityFilter: attr('string'),
|
||||||
metaDescription: attr('string'),
|
metaDescription: attr('string'),
|
||||||
metaTitle: attr('string'),
|
metaTitle: attr('string'),
|
||||||
mobiledoc: attr('json-string', {defaultValue: () => JSON.parse(JSON.stringify(BLANK_DOC))}),
|
mobiledoc: attr('json-string', {defaultValue: () => JSON.parse(JSON.stringify(BLANK_DOC))}),
|
||||||
|
@ -175,7 +176,7 @@ export default Model.extend(Comparable, ValidationEngine, {
|
||||||
return this.visibility === 'public' ? true : false;
|
return this.visibility === 'public' ? true : false;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
visibilitySegment: computed('visibility', 'isPublic', function () {
|
visibilitySegment: computed('visibility', 'visibilityFilter', 'isPublic', function () {
|
||||||
if (this.isPublic) {
|
if (this.isPublic) {
|
||||||
return this.settings.get('defaultContentVisibility') === 'paid' ? 'status:-free' : 'status:free,status:-free';
|
return this.settings.get('defaultContentVisibility') === 'paid' ? 'status:-free' : 'status:free,status:-free';
|
||||||
} else {
|
} else {
|
||||||
|
@ -185,6 +186,9 @@ export default Model.extend(Comparable, ValidationEngine, {
|
||||||
if (this.visibility === 'paid') {
|
if (this.visibility === 'paid') {
|
||||||
return 'status:-free';
|
return 'status:-free';
|
||||||
}
|
}
|
||||||
|
if (this.visibility === 'filter') {
|
||||||
|
return this.visibilityFilter;
|
||||||
|
}
|
||||||
return this.visibility;
|
return this.visibility;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -45,6 +45,12 @@ export default ApplicationSerializer.extend(EmbeddedRecordsMixin, {
|
||||||
|
|
||||||
if (json.visibility === null) {
|
if (json.visibility === null) {
|
||||||
delete json.visibility;
|
delete json.visibility;
|
||||||
|
delete json.visibility_filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (json.visibility === 'filter' && json.visibility_filter === null) {
|
||||||
|
delete json.visibility;
|
||||||
|
delete json.visibility_filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
|
|
|
@ -74,6 +74,13 @@ export default BaseValidator.create({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
visibilityFilter(model) {
|
||||||
|
if (isBlank(model.visibilityFilter) && !isBlank(model.visibility) && model.visibility === 'filter' && !model.isNew) {
|
||||||
|
model.errors.add('visibilityFilter', 'A members group must be selected for members-only posts');
|
||||||
|
this.invalidate();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
codeinjectionFoot(model) {
|
codeinjectionFoot(model) {
|
||||||
if (!validator.isLength(model.codeinjectionFoot || '', 0, 65535)) {
|
if (!validator.isLength(model.codeinjectionFoot || '', 0, 65535)) {
|
||||||
model.errors.add('codeinjectionFoot', 'Footer code cannot be longer than 65535 characters.');
|
model.errors.add('codeinjectionFoot', 'Footer code cannot be longer than 65535 characters.');
|
||||||
|
|
Loading…
Add table
Reference in a new issue