@@ -31,4 +31,17 @@ class PostAppealsController < ApplicationController
|
|||||||
fmt.html { redirect_to post_appeals_path(search: { id: @post_appeal.id }) }
|
fmt.html { redirect_to post_appeals_path(search: { id: @post_appeal.id }) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@post_appeal = authorize PostAppeal.find(params[:id])
|
||||||
|
respond_with(@post_appeal)
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@post_appeal = authorize PostAppeal.find(params[:id])
|
||||||
|
@post_appeal.update(permitted_attributes(@post_appeal))
|
||||||
|
respond_with(@post_appeal) do |fmt|
|
||||||
|
fmt.html { redirect_to post_path(@post_appeal.post) }
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,5 +1,17 @@
|
|||||||
class PostAppealPolicy < ApplicationPolicy
|
class PostAppealPolicy < ApplicationPolicy
|
||||||
def permitted_attributes
|
def edit?
|
||||||
|
update?
|
||||||
|
end
|
||||||
|
|
||||||
|
def update?
|
||||||
|
unbanned? && record.pending? && record.creator_id == user.id
|
||||||
|
end
|
||||||
|
|
||||||
|
def permitted_attributes_for_create
|
||||||
[:post_id, :reason]
|
[:post_id, :reason]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def permitted_attributes_for_update
|
||||||
|
[:reason]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,6 +6,10 @@
|
|||||||
<span class="prose"><em>no reason</em></span>
|
<span class="prose"><em>no reason</em></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% if policy(appeal).edit? %>
|
||||||
|
(<%= link_to "edit", edit_post_appeal_url(appeal) %>)
|
||||||
|
<% end %>
|
||||||
|
|
||||||
(<%= link_to_user(appeal.creator) %>, <%= time_ago_in_words_tagged(appeal.created_at) %>)
|
(<%= link_to_user(appeal.creator) %>, <%= time_ago_in_words_tagged(appeal.created_at) %>)
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
15
app/views/post_appeals/edit.html.erb
Normal file
15
app/views/post_appeals/edit.html.erb
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<div id="c-post-appeals">
|
||||||
|
<div id="a-edit">
|
||||||
|
<h1>Edit Appeal</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Editing appeal for <%= link_to "post ##{@post_appeal.post_id}", @post_appeal.post %>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<%= edit_form_for(@post_appeal) do |f| %>
|
||||||
|
<%= f.input :reason, as: :dtext, inline: true %>
|
||||||
|
<%= f.button :submit, "Submit" %>
|
||||||
|
<%= dtext_preview_button "post_appeal_reason" %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user