prevent new users from downvoting
don't show downvote arrows for logged-out and new users color comments from new users in green like in the user tree, and banned users in gray
This commit is contained in:
parent
0989d6b30b
commit
22b77573a5
|
@ -391,8 +391,8 @@ div.voters div.score {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
div.voters a.upvoter,
|
||||
div.voters a.downvoter {
|
||||
div.voters .upvoter,
|
||||
div.voters .downvoter {
|
||||
border-color: transparent transparent #bbb transparent;
|
||||
border-style: solid;
|
||||
border-width: 6px;
|
||||
|
@ -405,16 +405,16 @@ div.voters a.downvoter {
|
|||
display: block;
|
||||
}
|
||||
|
||||
div.voters a.upvoter:hover,
|
||||
li.upvoted div.voters a.upvoter {
|
||||
div.voters .upvoter:hover,
|
||||
li.upvoted div.voters .upvoter {
|
||||
border-bottom-color: #ac130d;
|
||||
}
|
||||
|
||||
div.voters a.upvoter {
|
||||
div.voters .upvoter {
|
||||
border-bottom-width: 11px;
|
||||
}
|
||||
|
||||
div.voters a.downvoter {
|
||||
div.voters .downvoter {
|
||||
border-color: #bbb transparent transparent transparent;
|
||||
border-width: 5px;
|
||||
margin-top: 4px;
|
||||
|
@ -422,11 +422,15 @@ div.voters a.downvoter {
|
|||
margin-bottom: -5px;
|
||||
border-top-width: 9px;
|
||||
}
|
||||
div.voters a.downvoter:hover,
|
||||
li.downvoted div.voters a.downvoter {
|
||||
div.voters .downvoter:hover,
|
||||
li.downvoted div.voters .downvoter {
|
||||
border-top-color: gray;
|
||||
}
|
||||
|
||||
div.voters .downvoter.downvoter_stub {
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
li.story,
|
||||
li.comment {
|
||||
clear: both;
|
||||
|
@ -503,6 +507,16 @@ li .byline a {
|
|||
color: #888;
|
||||
text-decoration: none;
|
||||
}
|
||||
.new_user,
|
||||
li .byline a.new_user {
|
||||
color: green;
|
||||
}
|
||||
.banned_user,
|
||||
li .byline a.banned_user {
|
||||
color: gray;
|
||||
text-decoration: line-through;
|
||||
}
|
||||
|
||||
|
||||
li.story.expired {
|
||||
opacity: 0.6;
|
||||
|
|
|
@ -8,7 +8,8 @@ class CommentsController < ApplicationController
|
|||
before_filter :find_user_from_rss_token, :only => [ :index ]
|
||||
|
||||
def create
|
||||
if !(story = Story.where(:short_id => params[:story_id]).first) || story.is_gone?
|
||||
if !(story = Story.where(:short_id => params[:story_id]).first) ||
|
||||
story.is_gone?
|
||||
return render :text => "can't find story", :status => 400
|
||||
end
|
||||
|
||||
|
@ -174,6 +175,10 @@ class CommentsController < ApplicationController
|
|||
return render :text => "invalid reason", :status => 400
|
||||
end
|
||||
|
||||
if !@user.can_downvote?
|
||||
return render :text => "not permitted to downvote", :status => 400
|
||||
end
|
||||
|
||||
Vote.vote_thusly_on_story_or_comment_for_user_because(-1, comment.story_id,
|
||||
comment.id, @user.id, params[:reason])
|
||||
|
||||
|
|
|
@ -238,6 +238,10 @@ class StoriesController < ApplicationController
|
|||
return render :text => "invalid reason", :status => 400
|
||||
end
|
||||
|
||||
if !@user.can_downvote?
|
||||
return render :text => "not permitted to downvote", :status => 400
|
||||
end
|
||||
|
||||
Vote.vote_thusly_on_story_or_comment_for_user_because(-1, story.id,
|
||||
nil, @user.id, params[:reason])
|
||||
|
||||
|
|
|
@ -92,8 +92,9 @@ class User < ActiveRecord::Base
|
|||
true
|
||||
end
|
||||
|
||||
def is_banned?
|
||||
banned_at?
|
||||
def can_downvote?
|
||||
# TODO: maybe change this to require a certain level of karma
|
||||
!is_new?
|
||||
end
|
||||
|
||||
def check_session_token
|
||||
|
@ -125,6 +126,14 @@ class User < ActiveRecord::Base
|
|||
PasswordReset.password_reset_link(self, ip).deliver
|
||||
end
|
||||
|
||||
def is_banned?
|
||||
banned_at?
|
||||
end
|
||||
|
||||
def is_new?
|
||||
Time.now - self.created_at <= 7.days
|
||||
end
|
||||
|
||||
def linkified_about
|
||||
# most users are probably mentioning "@username" to mean a twitter url, not
|
||||
# a link to a profile on this site
|
||||
|
|
|
@ -8,11 +8,17 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
|||
<%= comment.score <= -7 ? "negative_7" : "" %>">
|
||||
<% if !comment.is_gone? %>
|
||||
<div class="voters">
|
||||
<a class="upvoter"></a>
|
||||
<div class="score">
|
||||
<%= comment.score %>
|
||||
</div>
|
||||
<a class="downvoter"></a>
|
||||
<% if @user %>
|
||||
<a class="upvoter"></a>
|
||||
<% else %>
|
||||
<%= link_to "", login_url, :class => "upvoter" %>
|
||||
<% end %>
|
||||
<div class="score"><%= comment.score %></div>
|
||||
<% if @user && @user.can_downvote? %>
|
||||
<a class="downvoter"></a>
|
||||
<% else %>
|
||||
<span class="downvoter downvoter_stub"></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="details">
|
||||
|
@ -22,8 +28,13 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ?
|
|||
previewed
|
||||
just now
|
||||
<% else %>
|
||||
<a href="/u/<%= comment.user.username %>"><%= comment.user.username
|
||||
%></a>
|
||||
<a href="/u/<%= comment.user.username %>"
|
||||
<% if comment.user.is_banned? %>
|
||||
class="banned_user"
|
||||
<% elsif comment.user.is_new? %>
|
||||
class="new_user"
|
||||
<% end %>
|
||||
><%= comment.user.username %></a>
|
||||
|
||||
<%= comment.has_been_edited?? "edited" : "" %>
|
||||
<%= raw(time_ago_in_words_label(comment.has_been_edited? ?
|
||||
|
|
|
@ -8,10 +8,10 @@ class="story <%= story.vote == 1 ? "upvoted" : (story.vote == -1 ?
|
|||
<%= link_to "", login_url, :class => "upvoter" %>
|
||||
<% end %>
|
||||
<div class="score"><%= story.upvotes - story.downvotes %></div>
|
||||
<% if @user %>
|
||||
<% if @user && @user.can_downvote? %>
|
||||
<a class="downvoter"></a>
|
||||
<% else %>
|
||||
<%= link_to "", login_url, :class => "downvoter" %>
|
||||
<span class="downvoter downvoter_stub"></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="details">
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
<li>
|
||||
<a href="/u/<%= user.username %>"
|
||||
<% if user.is_banned? %>
|
||||
style="color: gray; text-decoration: line-through;"
|
||||
<% elsif Time.now - user.created_at < 7.days %>
|
||||
style="color: green;"
|
||||
class="banned_user"
|
||||
<% elsif user.is_new? %>
|
||||
class="new_user"
|
||||
<% end %>
|
||||
><%= user.username %></a> (<%= user.karma %>)
|
||||
<% if user.is_admin? %>
|
||||
|
|
Loading…
Reference in a new issue