From a5bee6836adef4fe25bdf022a13ea829e8622d43 Mon Sep 17 00:00:00 2001 From: Aaron Bushnell Date: Thu, 7 Aug 2014 09:59:31 -0400 Subject: [PATCH 1/4] Fix issue where users could comment on accepted/rejected submissions fix #31 --- client/views/posts/post_page.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/views/posts/post_page.js b/client/views/posts/post_page.js index 28a282b50d..313a30903b 100644 --- a/client/views/posts/post_page.js +++ b/client/views/posts/post_page.js @@ -8,9 +8,14 @@ Template.post_page.helpers({ return html_body.autoLink(); }, canComment: function(){ - return canComment(Meteor.user()); + var isAccepted = this.status === STATUS_IMPLEMENTED; + var isRejected = this.status === STATUS_REJECTED; + + if (canComment(Meteor.user()) && !isAccepted && !isRejected) { + return true; + } } -}); +}); Template.post_page.rendered = function(){ if((scrollToCommentId=Session.get('scrollToCommentId')) && !this.rendered && $('#'+scrollToCommentId).exists()){ From 97029a05c4e923f6348125aced3845988b8dd2a4 Mon Sep 17 00:00:00 2001 From: Aaron Bushnell Date: Thu, 7 Aug 2014 14:29:29 -0400 Subject: [PATCH 2/4] Add 'return false' when the canComment conditions are not met --- client/views/posts/post_page.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/views/posts/post_page.js b/client/views/posts/post_page.js index 313a30903b..3e2502c025 100644 --- a/client/views/posts/post_page.js +++ b/client/views/posts/post_page.js @@ -13,6 +13,8 @@ Template.post_page.helpers({ if (canComment(Meteor.user()) && !isAccepted && !isRejected) { return true; + } else { + return false; } } }); From f5ff6519eccd100987ff29b3d220d85a5c72af68 Mon Sep 17 00:00:00 2001 From: Aaron Bushnell Date: Thu, 7 Aug 2014 14:32:15 -0400 Subject: [PATCH 3/4] Add comment to show where global status variables are located --- client/views/posts/post_page.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/views/posts/post_page.js b/client/views/posts/post_page.js index 3e2502c025..dd1841b0e3 100644 --- a/client/views/posts/post_page.js +++ b/client/views/posts/post_page.js @@ -8,6 +8,7 @@ Template.post_page.helpers({ return html_body.autoLink(); }, canComment: function(){ + // STATUS_* variables are declared in the main application (/client/main.js) file var isAccepted = this.status === STATUS_IMPLEMENTED; var isRejected = this.status === STATUS_REJECTED; From a4d9c1b9839725d164f4ee5fece50023da053d33 Mon Sep 17 00:00:00 2001 From: Aaron Bushnell Date: Fri, 8 Aug 2014 14:27:29 -0400 Subject: [PATCH 4/4] Disable nested comments and voting if a post is rejected or accepted --- client/views/comments/comment_item.html | 24 +++++++++++++----------- client/views/comments/comment_item.js | 18 ++++++++++++++++-- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/client/views/comments/comment_item.html b/client/views/comments/comment_item.html index 8fc1adcc0e..b11fcbb3d6 100644 --- a/client/views/comments/comment_item.html +++ b/client/views/comments/comment_item.html @@ -2,16 +2,18 @@
  • - + {{#if isModifiable}} + + {{/if}}
    @@ -27,7 +29,7 @@ {{/if}}
    {{{body_formatted}}}
    - {{#if getSetting "nestedComments" true}} + {{#if isModifiable}} {{i18n "Reply"}} {{/if}}
    diff --git a/client/views/comments/comment_item.js b/client/views/comments/comment_item.js index 62ddbcb4fa..971db28a40 100644 --- a/client/views/comments/comment_item.js +++ b/client/views/comments/comment_item.js @@ -80,7 +80,7 @@ Template.comment_item.rendered=function(){ // note: testing on the class works because Meteor apparently preserves newly assigned CSS classes // across template renderings // TODO: save scroll position - + // get comment author name var user=Meteor.users.findOne(comment.userId); var author=getDisplayName(user); @@ -100,6 +100,20 @@ Template.comment_item.rendered=function(){ Template.comment_item.helpers({ + isModifiable: function() { + // STATUS_* variables are declared in the main application (/client/main.js) file + var isAccepted = Posts.findOne(this.post).status === STATUS_IMPLEMENTED; + var isRejected = Posts.findOne(this.post).status === STATUS_REJECTED; + + // Check if nested comments are enabled + var canNest = getSetting('nestedComments'); + + if (canNest && !isAccepted && !isRejected) { + return true; + } else { + return false; + } + }, full_date: function(){ var submitted = new Date(this.submitted); return submitted.toString(); @@ -149,7 +163,7 @@ Template.comment_item.helpers({ var user = Meteor.users.findOne(this.userId); if(user) return getProfileUrl(user); - } + } }); Template.comment_item.events({