This commit is contained in:
Toks
2013-04-14 12:56:35 -04:00
parent 59b9c2b76b
commit c9400e404d
5 changed files with 14 additions and 1 deletions

View File

@@ -4,6 +4,8 @@ class FavoritesController < ApplicationController
def index
if params[:tags]
redirect_to(posts_path(:tags => params[:tags]))
elsif request.format == Mime::JS
list_favorited_users
else
@favorite_set = PostSets::Favorite.new(CurrentUser.user, params[:page], params)
end
@@ -22,4 +24,9 @@ class FavoritesController < ApplicationController
@post = Post.find(params[:id])
@post.remove_favorite!(CurrentUser.user)
end
def list_favorited_users
@post = Post.find(params[:post_id])
render :action => "list_favorited_users"
end
end

View File

@@ -543,6 +543,10 @@ class Post < ActiveRecord::Base
def favorited_user_ids
fav_string.scan(/\d+/)
end
def favorited_users
favorited_user_ids.map {|id| User.find_by_id(id)}
end
end
module UploaderMethods

View File

@@ -0,0 +1 @@
<br><%= post.favorited_users.reverse_each.map{|user| link_to_user(user)}.join(", ").html_safe %>

View File

@@ -0,0 +1 @@
$("span#favlist-for-post-<%= @post.id %>").html("<%= j(render(:partial => "favorites/favorited_users_list", :locals => { :post => @post }))%>");

View File

@@ -14,7 +14,7 @@
<li>Source: <%= post_source_tag(post) %></li>
<li>Rating: <%= post.pretty_rating %></li>
<li>Score: <span id="score-for-post-<%= post.id %>"><%= post.score %></span> <% if CurrentUser.is_privileged? %>(vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %>)<% end %></li>
<li>Favorites: <span id="favcount-for-post-<%= post.id %>"><%= post.fav_count %></span></li>
<li>Favorites: <span id="favcount-for-post-<%= post.id %>"><%= post.fav_count %></span> <% if CurrentUser.is_privileged? && post.fav_count > 0 %><span id="favlist-for-post-<%= post.id %>"><%= link_to "&raquo;".html_safe, favorites_path(:post_id => post.id), :remote => true %></span><% end %></li>
<li>
Status:
<% if post.is_pending? %>