From 43c3f54264d88bf4689b4831e8e36e46ba274524 Mon Sep 17 00:00:00 2001 From: Vincent Widmer Date: Wed, 22 Aug 2018 11:54:55 +0200 Subject: [PATCH 1/7] Update permissions (liveFeedAddPost) --- .../templates/space/live_feed/live_feed.html | 4 ++- .../templates/space/live_feed/live_feed.js | 5 +++- .../space/live_feed/live_feed_post.html | 2 +- .../space/live_feed/live_feed_post.js | 23 ++++++-------- .../space/resources/resources_post.js | 16 +--------- .../space/settings/general_settings.js | 17 ----------- .../space/settings/permissions_settings.html | 1 + .../space/settings/permissions_settings.js | 22 ++++++++++++++ src/lib/collections/spaces.js | 6 ++-- src/private/version.json | 2 +- src/server/db_updates.js | 30 +++++++++++++++++++ src/settings.json | 2 +- 12 files changed, 75 insertions(+), 55 deletions(-) diff --git a/src/client/templates/space/live_feed/live_feed.html b/src/client/templates/space/live_feed/live_feed.html index e037d51..edb04aa 100644 --- a/src/client/templates/space/live_feed/live_feed.html +++ b/src/client/templates/space/live_feed/live_feed.html @@ -1,5 +1,7 @@ \ No newline at end of file diff --git a/src/client/templates/space/settings/permissions_settings.js b/src/client/templates/space/settings/permissions_settings.js index e3c1c60..7e32f59 100644 --- a/src/client/templates/space/settings/permissions_settings.js +++ b/src/client/templates/space/settings/permissions_settings.js @@ -43,5 +43,27 @@ Template.permissionsSettings.events({ if (error) alert(TAPi18n.__('error-message')+error.message); }); + }, + 'click .permissions-settings--liveFeedAddPost': function(e) { + e.preventDefault(); + + if (this.space.permissions) + if (this.space.permissions.liveFeedAddPost) { + Spaces.update(this.space._id, {$set: {permissions:{liveFeedAddPost:false}}}, function(error) { + if (error) + alert(TAPi18n.__('error-message')+error.message); + }); + } + else { + Spaces.update(this.space._id, {$set: {permissions:{liveFeedAddPost:true}}}, function(error) { + if (error) + alert(TAPi18n.__('error-message')+error.message); + }); + } + else + Spaces.update(this.space._id, {$set: {permissions:{liveFeedAddPost:true}}}, function(error) { + if (error) + alert(TAPi18n.__('error-message')+error.message); + }); } }); \ No newline at end of file diff --git a/src/lib/collections/spaces.js b/src/lib/collections/spaces.js index e850d93..9a7668a 100644 --- a/src/lib/collections/spaces.js +++ b/src/lib/collections/spaces.js @@ -96,14 +96,12 @@ if(Meteor.isServer) { submitted: new Date(), visible: true, codePanel: true, - guestWrite: true, - commentsAllowed:true, - postEditPermissions:"own", createUserAllowed:true, liveFeed:true, lessons:false, resources:true, - permissions:{public:false} + liveFeedComments:true, + permissions:{public:false, liveFeedAddPost:true} }); var spaceId = Spaces.insert(space); diff --git a/src/private/version.json b/src/private/version.json index e8d2db1..520befd 100644 --- a/src/private/version.json +++ b/src/private/version.json @@ -1,3 +1,3 @@ { - "version": "1.24" + "version": "1.25" } diff --git a/src/server/db_updates.js b/src/server/db_updates.js index 1cb813b..e5d2213 100644 --- a/src/server/db_updates.js +++ b/src/server/db_updates.js @@ -32,4 +32,34 @@ if (Categories.find({type:{$exists:false}}).count() > 0) { console.log('All categories without "order" attribute have been updated.'); } }); +} + + +// As of v1.25 +// Check if spaces have permissions attributes +console.log('Checking if spaces without "permissions" attribute exist and updating if so'); +if (Spaces.find({"permissions":{$exists:false}}).count() > 0) { + console.log('There are spaces without "permissions" attribute'); + Spaces.update({"permissions":{$exists:false}},{$set:{"permissions":{"public":false,"liveFeedAddPost":true}}}, function(err) { + if (err) { + console.log('Error when updating spaces without "permissions" attribute : '+error.message); + } + else { + console.log('All spaces without "permissions" attribute have been updated.'); + } + }); +} else { + //Check if spaces have permissions.liveFeedAddPost attributes + console.log('Checking if spaces without "permissions.liveFeedAddPost" attribute exist and updating if so'); + if (Spaces.find({"permissions.liveFeedAddPost":{$exists:false}}).count() > 0) { + console.log('There are spaces without "permissions.liveFeedAddPost" attribute'); + Spaces.update({"permissions.liveFeedAddPost":{$exists:false}},{$set:{"permissions":{"liveFeedAddPost":"own"}}}, function(err) { + if (err) { + console.log('Error when updating spaces without "permissions.liveFeedAddPost" attribute : '+error.message); + } + else { + console.log('All spaces without "permissions.liveFeedAddPost" attribute have been updated.'); + } + }); + } } \ No newline at end of file diff --git a/src/settings.json b/src/settings.json index 589b745..2a74855 100644 --- a/src/settings.json +++ b/src/settings.json @@ -8,7 +8,7 @@ "mailPassword": "", "mailServer": "", "public" : { - "isBox": "true", + "isBox": "false", "prefix": "XX", "ga": { "id": "" From 1786610fc4795b39178a13b15dfda212a9764980 Mon Sep 17 00:00:00 2001 From: Vincent Widmer Date: Wed, 22 Aug 2018 13:50:51 +0200 Subject: [PATCH 2/7] Fix permissions errors --- .../space/settings/permissions_settings.html | 2 +- .../space/settings/permissions_settings.js | 22 +++++++++--------- src/lib/collections/spaces.js | 2 +- src/server/db_updates.js | 23 ++++++++++++++++--- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/client/templates/space/settings/permissions_settings.html b/src/client/templates/space/settings/permissions_settings.html index 0bdccca..5cf532d 100644 --- a/src/client/templates/space/settings/permissions_settings.html +++ b/src/client/templates/space/settings/permissions_settings.html @@ -4,7 +4,7 @@
Permissions
{{#if isBox}} Public Space

Allows anyone to access the contents and interact within this Space without needing an Access Code.

{{#if space.permissions.public}}{{else}}{{/if}}
{{/if}} - Users can add categories in Live Feed{{#if space.permissions.addCategories}}{{else}}{{/if}} + Users can add categories in Live Feed{{#if space.permissions.liveFeedAddCategory}}{{else}}{{/if}} Users can add posts in Live Feed{{#if space.permissions.liveFeedAddPost}}{{else}}{{/if}} \ No newline at end of file diff --git a/src/client/templates/space/settings/permissions_settings.js b/src/client/templates/space/settings/permissions_settings.js index 7e32f59..46ea16d 100644 --- a/src/client/templates/space/settings/permissions_settings.js +++ b/src/client/templates/space/settings/permissions_settings.js @@ -5,41 +5,41 @@ Template.permissionsSettings.events({ if (this.space.permissions) if (this.space.permissions.public) { - Spaces.update(this.space._id, {$set: {permissions:{public:false}}}, function(error) { + Spaces.update(this.space._id, {$set: {"permissions.public":false}}, function(error) { if (error) alert(TAPi18n.__('error-message')+error.message); }); } else { - Spaces.update(this.space._id, {$set: {permissions:{public:true}}}, function(error) { + Spaces.update(this.space._id, {$set: {"permissions.public":true}}, function(error) { if (error) alert(TAPi18n.__('error-message')+error.message); }); } else - Spaces.update(this.space._id, {$set: {permissions:{public:true}}}, function(error) { + Spaces.update(this.space._id, {$set: {"permissions.public":true}}, function(error) { if (error) alert(TAPi18n.__('error-message')+error.message); }); }, - 'click .permissions-settings--addCategories': function(e) { + 'click .permissions-settings--liveFeedAddCategory': function(e) { e.preventDefault(); if (this.space.permissions) - if (this.space.permissions.addCategories) { - Spaces.update(this.space._id, {$set: {permissions:{addCategories:false}}}, function(error) { + if (this.space.permissions.liveFeedAddCategory) { + Spaces.update(this.space._id, {$set: {"permissions.liveFeedAddCategory":false}}, function(error) { if (error) alert(TAPi18n.__('error-message')+error.message); }); } else { - Spaces.update(this.space._id, {$set: {permissions:{addCategories:true}}}, function(error) { + Spaces.update(this.space._id, {$set: {"permissions.liveFeedAddCategory":true}}, function(error) { if (error) alert(TAPi18n.__('error-message')+error.message); }); } else - Spaces.update(this.space._id, {$set: {permissions:{addCategories:true}}}, function(error) { + Spaces.update(this.space._id, {$set: {"permissions.liveFeedAddCategory":true}}, function(error) { if (error) alert(TAPi18n.__('error-message')+error.message); }); @@ -49,19 +49,19 @@ Template.permissionsSettings.events({ if (this.space.permissions) if (this.space.permissions.liveFeedAddPost) { - Spaces.update(this.space._id, {$set: {permissions:{liveFeedAddPost:false}}}, function(error) { + Spaces.update(this.space._id, {$set: {"permissions.liveFeedAddPost":false}}, function(error) { if (error) alert(TAPi18n.__('error-message')+error.message); }); } else { - Spaces.update(this.space._id, {$set: {permissions:{liveFeedAddPost:true}}}, function(error) { + Spaces.update(this.space._id, {$set: {"permissions.liveFeedAddPost":true}}, function(error) { if (error) alert(TAPi18n.__('error-message')+error.message); }); } else - Spaces.update(this.space._id, {$set: {permissions:{liveFeedAddPost:true}}}, function(error) { + Spaces.update(this.space._id, {$set: {"permissions.liveFeedAddPost":true}}, function(error) { if (error) alert(TAPi18n.__('error-message')+error.message); }); diff --git a/src/lib/collections/spaces.js b/src/lib/collections/spaces.js index 9a7668a..3c6bef9 100644 --- a/src/lib/collections/spaces.js +++ b/src/lib/collections/spaces.js @@ -101,7 +101,7 @@ if(Meteor.isServer) { lessons:false, resources:true, liveFeedComments:true, - permissions:{public:false, liveFeedAddPost:true} + permissions:{public:false, liveFeedAddPost:true, liveFeedAddCategory:false} }); var spaceId = Spaces.insert(space); diff --git a/src/server/db_updates.js b/src/server/db_updates.js index e5d2213..c682b32 100644 --- a/src/server/db_updates.js +++ b/src/server/db_updates.js @@ -24,12 +24,13 @@ if (Posts.find({type:"home"}) != 0) { console.log('Checking if categories without "type" attribute exist and updating if so'); if (Categories.find({type:{$exists:false}}).count() > 0) { console.log('There are categories without "type" attribute'); - Categories.update({type:{$exists:false}},{$set:{"type":"liveFeed"}}, function(err) { // Before v1.2, categories was only available for liveFeed + Categories.update({type:{$exists:false}},{$set:{"type":"liveFeed"}}, function(err,res) { // Before v1.2, categories was only available for liveFeed if (err) { console.log('Error when updating categories without "type" attribute : '+error.message); } else { console.log('All categories without "order" attribute have been updated.'); + console.log(res); } }); } @@ -40,12 +41,13 @@ if (Categories.find({type:{$exists:false}}).count() > 0) { console.log('Checking if spaces without "permissions" attribute exist and updating if so'); if (Spaces.find({"permissions":{$exists:false}}).count() > 0) { console.log('There are spaces without "permissions" attribute'); - Spaces.update({"permissions":{$exists:false}},{$set:{"permissions":{"public":false,"liveFeedAddPost":true}}}, function(err) { + Spaces.update({"permissions":{$exists:false}},{$set:{"permissions":{"public":false,"liveFeedAddPost":true,"liveFeedAddCategory":false}}}, function(err,res) { if (err) { console.log('Error when updating spaces without "permissions" attribute : '+error.message); } else { console.log('All spaces without "permissions" attribute have been updated.'); + console.log(res); } }); } else { @@ -53,12 +55,27 @@ if (Spaces.find({"permissions":{$exists:false}}).count() > 0) { console.log('Checking if spaces without "permissions.liveFeedAddPost" attribute exist and updating if so'); if (Spaces.find({"permissions.liveFeedAddPost":{$exists:false}}).count() > 0) { console.log('There are spaces without "permissions.liveFeedAddPost" attribute'); - Spaces.update({"permissions.liveFeedAddPost":{$exists:false}},{$set:{"permissions":{"liveFeedAddPost":"own"}}}, function(err) { + Spaces.update({"permissions.liveFeedAddPost":{$exists:false}},{$set:{"permissions.liveFeedAddPost":"own"}}, function(err,res) { if (err) { console.log('Error when updating spaces without "permissions.liveFeedAddPost" attribute : '+error.message); } else { console.log('All spaces without "permissions.liveFeedAddPost" attribute have been updated.'); + console.log(res); + } + }); + } + //Check if spaces have permissions.liveFeedAddCategory attributes + console.log('Checking if spaces without "permissions.liveFeedAddCategory" attribute exist and updating if so'); + if (Spaces.find({"permissions.liveFeedAddCategory":{$exists:false}}).count() > 0) { + console.log('There are spaces without "permissions.liveFeedAddCategory" attribute'); + Spaces.update({"permissions.liveFeedAddCategory":{$exists:false}},{$set:{"permissions.liveFeedAddCategory":false}}, function(err,res) { + if (err) { + console.log('Error when updating spaces without "permissions.liveFeedAddCategory" attribute : '+error.message); + } + else { + console.log('All spaces without "permissions.liveFeedAddCategory" attribute have been updated:'); + console.log(res); } }); } From aee29cc2df9cadf3044e0a10ab43a7e8b0b12c57 Mon Sep 17 00:00:00 2001 From: Vincent Widmer Date: Wed, 22 Aug 2018 13:55:01 +0200 Subject: [PATCH 3/7] Update version --- src/private/version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/private/version.json b/src/private/version.json index 520befd..74de79d 100644 --- a/src/private/version.json +++ b/src/private/version.json @@ -1,3 +1,3 @@ { - "version": "1.25" + "version": "1.26" } From d61249b64bff5d8cc7062a4c91b9951a97380859 Mon Sep 17 00:00:00 2001 From: Vincent Widmer Date: Wed, 22 Aug 2018 14:05:35 +0200 Subject: [PATCH 4/7] Fix addCategory permission bug --- src/client/templates/space/space_sidebar.html | 2 +- src/client/templates/space/space_sidebar.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/templates/space/space_sidebar.html b/src/client/templates/space/space_sidebar.html index c9b78c0..2fa249e 100644 --- a/src/client/templates/space/space_sidebar.html +++ b/src/client/templates/space/space_sidebar.html @@ -25,7 +25,7 @@ {{/each}}
- {{#if permissionAddCategories}} + {{#if liveFeedAddCategory}} {{_ 'space-sidebar--add-category'}} diff --git a/src/client/templates/space/space_sidebar.js b/src/client/templates/space/space_sidebar.js index fd71621..7334538 100644 --- a/src/client/templates/space/space_sidebar.js +++ b/src/client/templates/space/space_sidebar.js @@ -139,8 +139,14 @@ Template.spaceSidebar.helpers({ resources: function() { return this.space.resources }, - liveFeedAddCategories: function() { - if (this.space.permissions.liveFeedAddCategories || Roles.userIsInRole(Meteor.userId(), ['admin']) || Meteor.userId() == this.space.userId) + ownSpace: function() { + if (Meteor.userId() == Template.parentData(2).space.userId || Roles.userIsInRole(Meteor.userId(), ['admin'])) + return true + else + return false + }, + liveFeedAddCategory: function() { + if (this.space.permissions.liveFeedAddCategory || Roles.userIsInRole(Meteor.userId(), ['admin']) || Meteor.userId() == this.space.userId) return true else return false From 4b806313082e39a2af67c1e20f6223f167f28f05 Mon Sep 17 00:00:00 2001 From: Vincent Widmer Date: Wed, 22 Aug 2018 14:28:38 +0200 Subject: [PATCH 7/7] Update version --- src/private/version.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/private/version.json b/src/private/version.json index 8e09bf1..f36aa22 100644 --- a/src/private/version.json +++ b/src/private/version.json @@ -1,3 +1,3 @@ { - "version": "1.26b" + "version": "1.26c" }