mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Members post gating options (#11160)
no issue - Removed uses of `visibility` column in frontend url service configs - The value of `visibility` is always set to 'public' in posts at the moment and doesn't serve any specific purpose when used with these filters. - Allowed new visibility attributes in post model - `posts.visibility` column is being repurposed for the needs of member content gating - Added test for visibility editing in Admin API - Corrected test schema checks for Admin API post/page responses
This commit is contained in:
parent
56493bed1a
commit
ff13821b27
14 changed files with 66 additions and 15 deletions
|
@ -8,7 +8,7 @@ module.exports = [
|
|||
type: 'posts',
|
||||
modelOptions: {
|
||||
modelName: 'Post',
|
||||
filter: 'visibility:public+status:published+page:false',
|
||||
filter: 'status:published+page:false',
|
||||
exclude: [
|
||||
'title',
|
||||
'mobiledoc',
|
||||
|
@ -79,7 +79,7 @@ module.exports = [
|
|||
'primary_tag',
|
||||
'primary_author'
|
||||
],
|
||||
filter: 'visibility:public+status:published+page:true'
|
||||
filter: 'status:published+page:true'
|
||||
},
|
||||
events: {
|
||||
add: 'page.published',
|
||||
|
|
|
@ -8,7 +8,7 @@ module.exports = [
|
|||
type: 'posts',
|
||||
modelOptions: {
|
||||
modelName: 'Post',
|
||||
filter: 'visibility:public+status:published+page:false',
|
||||
filter: 'status:published+page:false',
|
||||
exclude: [
|
||||
'title',
|
||||
'mobiledoc',
|
||||
|
@ -73,7 +73,7 @@ module.exports = [
|
|||
'primary_tag',
|
||||
'primary_author'
|
||||
],
|
||||
filter: 'visibility:public+status:published+page:true'
|
||||
filter: 'status:published+page:true'
|
||||
},
|
||||
events: {
|
||||
add: 'page.published',
|
||||
|
|
|
@ -8,7 +8,7 @@ module.exports = [
|
|||
type: 'posts',
|
||||
modelOptions: {
|
||||
modelName: 'Post',
|
||||
filter: 'visibility:public+status:published+page:false',
|
||||
filter: 'status:published+page:false',
|
||||
exclude: [
|
||||
'title',
|
||||
'mobiledoc',
|
||||
|
|
|
@ -98,6 +98,8 @@ const post = (attrs, frame) => {
|
|||
if (attrs.og_description === '') {
|
||||
attrs.og_description = null;
|
||||
}
|
||||
|
||||
delete attrs.visibility;
|
||||
} else {
|
||||
delete attrs.page;
|
||||
|
||||
|
@ -111,7 +113,6 @@ const post = (attrs, frame) => {
|
|||
}
|
||||
|
||||
delete attrs.locale;
|
||||
delete attrs.visibility;
|
||||
delete attrs.author;
|
||||
|
||||
return attrs;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
},
|
||||
"visibility": {
|
||||
"type": ["string", "null"],
|
||||
"enum": ["public"]
|
||||
"enum": ["public", "members", "paid"]
|
||||
},
|
||||
"meta_title": {
|
||||
"type": ["string", "null"],
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
},
|
||||
"visibility": {
|
||||
"type": ["string", "null"],
|
||||
"enum": ["public"]
|
||||
"enum": ["public", "members", "paid"]
|
||||
},
|
||||
"meta_title": {
|
||||
"type": ["string", "null"],
|
||||
|
|
|
@ -98,6 +98,8 @@ const post = (attrs, frame) => {
|
|||
if (attrs.og_description === '') {
|
||||
attrs.og_description = null;
|
||||
}
|
||||
|
||||
delete attrs.visibility;
|
||||
} else {
|
||||
delete attrs.page;
|
||||
|
||||
|
@ -111,7 +113,6 @@ const post = (attrs, frame) => {
|
|||
}
|
||||
|
||||
delete attrs.locale;
|
||||
delete attrs.visibility;
|
||||
delete attrs.author;
|
||||
|
||||
return attrs;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
},
|
||||
"visibility": {
|
||||
"type": ["string", "null"],
|
||||
"enum": ["public"]
|
||||
"enum": ["public", "members", "paid"]
|
||||
},
|
||||
"meta_title": {
|
||||
"type": ["string", "null"],
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
},
|
||||
"visibility": {
|
||||
"type": ["string", "null"],
|
||||
"enum": ["public"]
|
||||
"enum": ["public", "members", "paid"]
|
||||
},
|
||||
"meta_title": {
|
||||
"type": ["string", "null"],
|
||||
|
|
|
@ -27,7 +27,7 @@ module.exports = {
|
|||
maxlength: 50,
|
||||
nullable: false,
|
||||
defaultTo: 'public',
|
||||
validations: {isIn: [['public']]}
|
||||
validations: {isIn: [['public', 'members', 'paid']]}
|
||||
},
|
||||
meta_title: {type: 'string', maxlength: 2000, nullable: true, validations: {isLength: {max: 300}}},
|
||||
meta_description: {type: 'string', maxlength: 2000, nullable: true, validations: {isLength: {max: 500}}},
|
||||
|
|
|
@ -28,7 +28,6 @@ const expectedProperties = {
|
|||
.keys()
|
||||
// by default we only return mobildoc
|
||||
.without('html', 'plaintext')
|
||||
.without('visibility')
|
||||
.without('locale')
|
||||
.without('page')
|
||||
// deprecated
|
||||
|
@ -43,7 +42,6 @@ const expectedProperties = {
|
|||
.keys()
|
||||
// by default we only return mobildoc
|
||||
.without('html', 'plaintext')
|
||||
.without('visibility')
|
||||
.without('locale')
|
||||
.without('page')
|
||||
// deprecated
|
||||
|
|
|
@ -342,6 +342,32 @@ describe('Posts API', function () {
|
|||
res.body.posts[0].slug.should.equal('this-is-invisible');
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts visibility parameter', function () {
|
||||
return request
|
||||
.get(localUtils.API.getApiQuery(`posts/${testUtils.DataGenerator.Content.posts[0].id}/`))
|
||||
.set('Origin', config.get('url'))
|
||||
.expect(200)
|
||||
.then((res) => {
|
||||
return request
|
||||
.put(localUtils.API.getApiQuery('posts/' + testUtils.DataGenerator.Content.posts[0].id + '/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.send({
|
||||
posts: [{
|
||||
visibility: 'members',
|
||||
updated_at: res.body.posts[0].updated_at
|
||||
}]
|
||||
})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(200);
|
||||
})
|
||||
.then((res) => {
|
||||
should.exist(res.body.posts);
|
||||
should.exist(res.body.posts[0].visibility);
|
||||
res.body.posts[0].visibility.should.equal('members');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Destroy', function () {
|
||||
|
|
|
@ -22,7 +22,6 @@ const expectedProperties = {
|
|||
.keys()
|
||||
// by default we only return mobiledoc
|
||||
.without('html', 'plaintext')
|
||||
.without('visibility')
|
||||
.without('locale')
|
||||
.without('page')
|
||||
.without('author_id')
|
||||
|
|
|
@ -342,6 +342,32 @@ describe('Posts API', function () {
|
|||
res.body.posts[0].slug.should.equal('this-is-invisible');
|
||||
});
|
||||
});
|
||||
|
||||
it('accepts visibility parameter', function () {
|
||||
return request
|
||||
.get(localUtils.API.getApiQuery(`posts/${testUtils.DataGenerator.Content.posts[0].id}/`))
|
||||
.set('Origin', config.get('url'))
|
||||
.expect(200)
|
||||
.then((res) => {
|
||||
return request
|
||||
.put(localUtils.API.getApiQuery('posts/' + testUtils.DataGenerator.Content.posts[0].id + '/'))
|
||||
.set('Origin', config.get('url'))
|
||||
.send({
|
||||
posts: [{
|
||||
visibility: 'members',
|
||||
updated_at: res.body.posts[0].updated_at
|
||||
}]
|
||||
})
|
||||
.expect('Content-Type', /json/)
|
||||
.expect('Cache-Control', testUtils.cacheRules.private)
|
||||
.expect(200);
|
||||
})
|
||||
.then((res) => {
|
||||
should.exist(res.body.posts);
|
||||
should.exist(res.body.posts[0].visibility);
|
||||
res.body.posts[0].visibility.should.equal('members');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Destroy', function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue