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