Add key shortcut to add to favgroup

This commit is contained in:
Toks
2015-07-01 11:16:07 -04:00
parent 654abe60ed
commit 81f588e021
8 changed files with 73 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
class FavoriteGroupsController < ApplicationController
before_filter :member_only, :except => [:index, :show]
respond_to :html, :xml, :json
respond_to :html, :xml, :json, :js
def index
@favorite_groups = FavoriteGroup.search(params[:search]).order("updated_at desc").paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
@@ -59,6 +59,13 @@ class FavoriteGroupsController < ApplicationController
redirect_to favorite_groups_path
end
def add_post
@favorite_group = FavoriteGroup.find(params[:id])
check_privilege(@favorite_group)
@post = Post.find(params[:post_id])
@favorite_group.add!(@post)
end
private
def check_privilege(favgroup)
raise User::PrivilegeError unless favgroup.editable_by?(CurrentUser.user)