forked from e621ng/e621ng
Add deleted posts index
This commit is contained in:
parent
b355fde206
commit
5db95b362b
14
app/controllers/deleted_posts_controller.rb
Normal file
14
app/controllers/deleted_posts_controller.rb
Normal 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
|
@ -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)
|
||||
|
27
app/views/deleted_posts/index.html.erb
Normal file
27
app/views/deleted_posts/index.html.erb
Normal 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>
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user