Add deleted posts index

This commit is contained in:
Kira 2020-04-05 07:30:12 -07:00
parent b355fde206
commit 5db95b362b
4 changed files with 43 additions and 1 deletions

View File

@ -0,0 +1,14 @@
class DeletedPostsController < ApplicationController
before_action :member_only
respond_to :html
def index
@posts = Post.where(is_deleted: true)
if params[:user_id].present?
@user = User.find(params[:user_id])
@posts = @posts.where('posts.uploader_id = ?', @user.id)
end
@posts = @posts.includes(:uploader).includes(:flags).order(Arel.sql('post_flags.created_at DESC')).paginate(params[:page])
end
end

View File

@ -75,7 +75,7 @@ class UserPresenter
end
def deleted_upload_count(template)
template.link_to(user.post_deleted_count, template.posts_path(:tags => "status:deleted user:#{user.name}"))
template.link_to(user.post_deleted_count, template.deleted_posts_path(user_id: user.id))
end
def favorite_count(template)

View File

@ -0,0 +1,27 @@
<h4>Deleted Posts</h4>
<table class='table'>
<thead>
<tr>
<th width="7%">Post</th>
<th width="10%">Poster</th>
<th width="48%">Tags</th>
<th width="35%">Reason</th>
</tr>
</thead>
<tbody>
<% @posts.each do |post| %>
<tr>
<td><%= link_to post.id, post_path(post) %></td>
<td><%= link_to_user post.uploader %></td>
<td><%= post.tag_string %></td>
<td><%= post.flags.last&.reason %></td>
</tr>
<% end %>
</tbody>
</table>
<div id="paginator">
<%= numbered_paginator(@posts) %>
</div>

View File

@ -243,6 +243,7 @@ Rails.application.routes.draw do
end
end
resources :post_replacements, :only => [:index, :new, :create, :update]
resources :deleted_posts, only: [:index]
resources :posts, :only => [:index, :show, :update] do
resources :events, :only => [:index], :controller => "post_events"
resources :replacements, :only => [:index, :new, :create], :controller => "post_replacements"