Comment: cap downvotes to -5, only collapse when it reaches
This commit is contained in:
parent
05743959cf
commit
e8d11e28d7
|
@ -476,10 +476,10 @@ li div.details {
|
||||||
opacity: 0.7;
|
opacity: 0.7;
|
||||||
}
|
}
|
||||||
.negative_3 {
|
.negative_3 {
|
||||||
opacity: 0.5;
|
opacity: 0.6;
|
||||||
}
|
}
|
||||||
.negative_5 {
|
.negative_5 {
|
||||||
opacity: 0.2;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
.comment.highlighted {
|
.comment.highlighted {
|
||||||
|
|
|
@ -26,6 +26,9 @@ class Comment < ActiveRecord::Base
|
||||||
|
|
||||||
DOWNVOTABLE_DAYS = 7
|
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
|
# after this many minutes old, a comment cannot be edited
|
||||||
MAX_EDIT_MINS = (60 * 6)
|
MAX_EDIT_MINS = (60 * 6)
|
||||||
|
|
||||||
|
@ -321,7 +324,7 @@ class Comment < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_downvotable?
|
def is_downvotable?
|
||||||
if self.created_at
|
if self.created_at && self.score >= DOWNVOTABLE_MIN_SCORE
|
||||||
Time.now - self.created_at <= DOWNVOTABLE_DAYS.days
|
Time.now - self.created_at <= DOWNVOTABLE_DAYS.days
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
|
|
|
@ -341,8 +341,7 @@ class Story < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_downvotable?
|
def is_downvotable?
|
||||||
return true
|
if self.created_at && self.score >= -5
|
||||||
if self.created_at
|
|
||||||
Time.now - self.created_at <= DOWNVOTABLE_DAYS.days
|
Time.now - self.created_at <= DOWNVOTABLE_DAYS.days
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
|
|
|
@ -65,7 +65,7 @@ class User < ActiveRecord::Base
|
||||||
MIN_KARMA_TO_SUGGEST = 10
|
MIN_KARMA_TO_SUGGEST = 10
|
||||||
|
|
||||||
# minimum karma required to be able to downvote comments
|
# 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
|
# minimum karma required to be able to submit new stories
|
||||||
MIN_KARMA_TO_SUBMIT_STORIES = -4
|
MIN_KARMA_TO_SUBMIT_STORIES = -4
|
||||||
|
@ -176,7 +176,7 @@ class User < ActiveRecord::Base
|
||||||
# user can unvote
|
# user can unvote
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
elsif obj.is_a?(Comment)
|
elsif obj.is_a?(Comment) && obj.is_downvotable?
|
||||||
return !self.is_new? && (self.karma >= MIN_KARMA_TO_DOWNVOTE)
|
return !self.is_new? && (self.karma >= MIN_KARMA_TO_DOWNVOTE)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
<input id="comment_folder_<%= comment.short_id %>"
|
<input id="comment_folder_<%= comment.short_id %>"
|
||||||
class="comment_folder_button" type="checkbox"
|
class="comment_folder_button" type="checkbox"
|
||||||
<%= comment.score <= -1 ? "checked" : "" %>>
|
<%= comment.score <= Comment::DOWNVOTABLE_MIN_SCORE ? "checked" : "" %>>
|
||||||
<div id="comment_<%= comment.short_id %>"
|
<div id="comment_<%= comment.short_id %>"
|
||||||
data-shortid="<%= comment.short_id if comment.persisted? %>"
|
data-shortid="<%= comment.short_id if comment.persisted? %>"
|
||||||
class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
||||||
"upvoted" : "downvoted") : "" %>
|
"upvoted" : "downvoted") : "" %>
|
||||||
<%= comment.highlighted ? "highlighted" : "" %>
|
<%= 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? %>
|
<% if !comment.is_gone? %>
|
||||||
<div class="voters">
|
<div class="voters">
|
||||||
<% if @user %>
|
<% if @user %>
|
||||||
|
|
Loading…
Reference in a new issue