Permalink
Browse files
Comment: cap downvotes to -5, only collapse when it reaches that
- Loading branch information...
|
|
@@ -476,10 +476,10 @@ li div.details { |
|
|
opacity: 0.7;
|
|
|
}
|
|
|
.negative_3 {
|
|
|
opacity: 0.5;
|
|
|
opacity: 0.6;
|
|
|
}
|
|
|
.negative_5 {
|
|
|
opacity: 0.2;
|
|
|
opacity: 0.5;
|
|
|
}
|
|
|
|
|
|
.comment.highlighted {
|
|
|
|
|
|
@@ -26,6 +26,9 @@ class Comment < ActiveRecord::Base |
|
|
|
|
|
DOWNVOTABLE_DAYS = 7
|
|
|
|
|
|
# the lowest a score can go, which makes it collapsed by default
|
|
|
DOWNVOTABLE_MIN_SCORE = -5
|
|
|
|
|
|
# after this many minutes old, a comment cannot be edited
|
|
|
MAX_EDIT_MINS = (60 * 6)
|
|
|
|
|
|
@@ -323,7 +326,7 @@ def is_deletable_by_user?(user) |
|
|
end
|
|
|
|
|
|
def is_downvotable?
|
|
|
if self.created_at
|
|
|
if self.created_at && self.score >= DOWNVOTABLE_MIN_SCORE
|
|
|
Time.now - self.created_at <= DOWNVOTABLE_DAYS.days
|
|
|
else
|
|
|
false
|
|
|
|
|
|
@@ -341,8 +341,7 @@ def html_class_for_user |
|
|
end
|
|
|
|
|
|
def is_downvotable?
|
|
|
return true
|
|
|
if self.created_at
|
|
|
if self.created_at && self.score >= -5
|
|
|
Time.now - self.created_at <= DOWNVOTABLE_DAYS.days
|
|
|
else
|
|
|
false
|
|
|
|
|
|
@@ -65,7 +65,7 @@ class User < ActiveRecord::Base |
|
|
MIN_KARMA_TO_SUGGEST = 10
|
|
|
|
|
|
# minimum karma required to be able to downvote comments
|
|
|
MIN_KARMA_TO_DOWNVOTE = 100
|
|
|
MIN_KARMA_TO_DOWNVOTE = 50
|
|
|
|
|
|
# minimum karma required to be able to submit new stories
|
|
|
MIN_KARMA_TO_SUBMIT_STORIES = -4
|
|
|
@@ -176,7 +176,7 @@ def can_downvote?(obj) |
|
|
# user can unvote
|
|
|
return true
|
|
|
end
|
|
|
elsif obj.is_a?(Comment)
|
|
|
elsif obj.is_a?(Comment) && obj.is_downvotable?
|
|
|
return !self.is_new? && (self.karma >= MIN_KARMA_TO_DOWNVOTE)
|
|
|
end
|
|
|
|
|
|
|
|
|
@@ -1,13 +1,14 @@ |
|
|
<input id="comment_folder_<%= comment.short_id %>"
|
|
|
class="comment_folder_button" type="checkbox"
|
|
|
<%= comment.score <= -1 ? "checked" : "" %>>
|
|
|
<%= comment.score <= Comment::DOWNVOTABLE_MIN_SCORE ? "checked" : "" %>>
|
|
|
<div id="comment_<%= comment.short_id %>"
|
|
|
data-shortid="<%= comment.short_id if comment.persisted? %>"
|
|
|
class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
|
|
"upvoted" : "downvoted") : "" %>
|
|
|
<%= comment.highlighted ? "highlighted" : "" %>
|
|
|
<%= comment.score <= 0 ? "negative" : "" %>
|
|
|
<%= comment.score <= -1 ? "negative_1" : "" %>">
|
|
|
<%= comment.score <= -1 ? "negative_1" : "" %>
|
|
|
<%= comment.score <= -3 ? "negative_3" : "" %>
|
|
|
<%= comment.score <= -5 ? "negative_5" : "" %>">
|
|
|
<% if !comment.is_gone? %>
|
|
|
<div class="voters">
|
|
|
<% if @user %>
|
|
|
|
0 comments on commit
3c56d51