Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where users could comment on accepted/rejected submissions #35

Open
wants to merge 4 commits into
base: a2-build
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions client/views/comments/comment_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
<li class="comment comment-displayed" id="{{_id}}">
<div class="comment-body">
<div class="comment-content">
<div class="comment-actions {{#if upvoted}}upvoted{{else}}not-upvoted{{/if}} {{#if downvoted}}downvoted{{else}}not-downvoted{{/if}}">
<a class="upvote" href="#">
<i class="icon-up"></i>
<span>{{i18n "upvote"}}</span>
</a>
<a class="downvote" href="#">
<i class="icon-down"></i>
<span>{{i18n "downvote"}}</span>
</a>
</div>
{{#if isModifiable}}
<div class="comment-actions {{#if upvoted}}upvoted{{else}}not-upvoted{{/if}} {{#if downvoted}}downvoted{{else}}not-downvoted{{/if}}">
<a class="upvote" href="#">
<i class="icon-up"></i>
<span>{{i18n "upvote"}}</span>
</a>
<a class="downvote" href="#">
<i class="icon-down"></i>
<span>{{i18n "downvote"}}</span>
</a>
</div>
{{/if}}
<div class="user-avatar"><img src="{{user_avatar}}" /></div>
<div class="comment-main">
<div class="comment-meta">
Expand All @@ -27,7 +29,7 @@
{{/if}}
</div>
<div class="comment-text markdown">{{{body_formatted}}}</div>
{{#if getSetting "nestedComments" true}}
{{#if isModifiable}}
<a href="/comments/{{_id}}/reply" class="comment-reply goto-comment">{{i18n "Reply"}}</a>
{{/if}}
</div>
Expand Down
18 changes: 16 additions & 2 deletions client/views/comments/comment_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -149,7 +163,7 @@ Template.comment_item.helpers({
var user = Meteor.users.findOne(this.userId);
if(user)
return getProfileUrl(user);
}
}
});

Template.comment_item.events({
Expand Down
12 changes: 10 additions & 2 deletions client/views/posts/post_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ Template.post_page.helpers({
return html_body.autoLink();
},
canComment: function(){
return canComment(Meteor.user());
// STATUS_* variables are declared in the main application (/client/main.js) file
var isAccepted = this.status === STATUS_IMPLEMENTED;
var isRejected = this.status === STATUS_REJECTED;

if (canComment(Meteor.user()) && !isAccepted && !isRejected) {
return true;
} else {
return false;
}
}
});
});

Template.post_page.rendered = function(){
if((scrollToCommentId=Session.get('scrollToCommentId')) && !this.rendered && $('#'+scrollToCommentId).exists()){
Expand Down