post approvals: add to post events page.
This commit is contained in:
@@ -4,11 +4,11 @@ class PostEvent
|
||||
include ActiveModel::Serializers::Xml
|
||||
|
||||
attr_accessor :event
|
||||
delegate :creator, :creator_id, :reason, :is_resolved, :created_at, to: :event
|
||||
delegate :created_at, to: :event
|
||||
|
||||
def self.find_for_post(post_id)
|
||||
post = Post.find(post_id)
|
||||
(post.appeals + post.flags).sort_by(&:created_at).reverse.map { |e| new(event: e) }
|
||||
(post.appeals + post.flags + post.approvals).sort_by(&:created_at).reverse.map { |e| new(event: e) }
|
||||
end
|
||||
|
||||
def type_name
|
||||
@@ -17,6 +17,8 @@ class PostEvent
|
||||
"flag"
|
||||
when PostAppeal
|
||||
"appeal"
|
||||
when PostApproval
|
||||
"approval"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,9 +26,25 @@ class PostEvent
|
||||
type_name.first
|
||||
end
|
||||
|
||||
def reason
|
||||
event.try(:reason) || ""
|
||||
end
|
||||
|
||||
def is_resolved
|
||||
event.try(:is_resolved) || false
|
||||
end
|
||||
|
||||
def creator_id
|
||||
event.try(:creator_id) || event.try(:user_id)
|
||||
end
|
||||
|
||||
def creator
|
||||
event.try(:creator) || event.try(:user)
|
||||
end
|
||||
|
||||
def is_creator_visible?(user = CurrentUser.user)
|
||||
case event
|
||||
when PostAppeal
|
||||
when PostAppeal, PostApproval
|
||||
true
|
||||
when PostFlag
|
||||
flag = event
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<div id="c-post-events">
|
||||
<div id="a-index">
|
||||
<h1>Flags & Appeals</h1>
|
||||
<h1>Post Events</h1>
|
||||
|
||||
<table width="100%" class="striped">
|
||||
<table width="100%" class="striped autofit">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%">Type</th>
|
||||
<th width="10%">Creator</th>
|
||||
<th>Reason</th>
|
||||
<th width="5%">Resolved?</th>
|
||||
<th width="15%">Date</th>
|
||||
<th>Type</th>
|
||||
<th>User</th>
|
||||
<th>Description</th>
|
||||
<th>Resolved?</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -22,16 +21,10 @@
|
||||
<% else %>
|
||||
<i>hidden</i>
|
||||
<% end %>
|
||||
<br><%= time_ago_in_words_tagged event.created_at %>
|
||||
</td>
|
||||
<td><%= format_text event.reason %></td>
|
||||
<td>
|
||||
<% if event.is_resolved %>
|
||||
yes
|
||||
<% else %>
|
||||
no
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= compact_time event.created_at %></td>
|
||||
<td class="col-expand"><%= format_text event.reason %></td>
|
||||
<td><%= event.is_resolved %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
|
||||
@@ -9,15 +9,16 @@ class PostEventsControllerTest < ActionDispatch::IntegrationTest
|
||||
|
||||
as_user do
|
||||
@post = create(:post)
|
||||
@post_flag = PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false)
|
||||
@post_appeal = PostAppeal.create(:post => @post, :reason => "aaa")
|
||||
@post.flag!("aaa")
|
||||
@post.appeal!("aaa")
|
||||
@post.approve!(@mod)
|
||||
end
|
||||
end
|
||||
|
||||
context "get /posts/:post_id/events" do
|
||||
should "render" do
|
||||
get_auth post_events_path(post_id: @post.id), @user
|
||||
assert_response :ok
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
should "render for mods" do
|
||||
|
||||
Reference in New Issue
Block a user