Fix #4982: Add route to remove a post from a favorite group
This commit is contained in:
@@ -59,4 +59,12 @@ class FavoriteGroupsController < ApplicationController
|
||||
|
||||
respond_with(@favorite_group)
|
||||
end
|
||||
|
||||
def remove_post
|
||||
@favorite_group = authorize FavoriteGroup.find(params[:id])
|
||||
@post = Post.find(params[:post_id])
|
||||
@favorite_group.remove(@post)
|
||||
|
||||
respond_with(@favorite_group)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,6 +17,10 @@ class FavoriteGroupPolicy < ApplicationPolicy
|
||||
update?
|
||||
end
|
||||
|
||||
def remove_post?
|
||||
update?
|
||||
end
|
||||
|
||||
def can_enable_privacy?
|
||||
record.creator.is_gold?
|
||||
end
|
||||
|
||||
7
app/views/favorite_groups/remove_post.js.erb
Normal file
7
app/views/favorite_groups/remove_post.js.erb
Normal file
@@ -0,0 +1,7 @@
|
||||
<% if @favorite_group.errors.any? %>
|
||||
Danbooru.notice("<%= j @favorite_group.errors.full_messages.join("; ") %>");
|
||||
<% else %>
|
||||
Danbooru.notice("Removed post from favorite group <%= j @favorite_group.pretty_name %>");
|
||||
<% end %>
|
||||
|
||||
$("#add-to-favgroup-dialog").dialog("close");
|
||||
Reference in New Issue
Block a user