fixes #1350, better db:seed script
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
module Moderator
|
||||
module Post
|
||||
class PostsController < ApplicationController
|
||||
before_filter :janitor_only, :only => [:delete, :undelete]
|
||||
before_filter :janitor_only, :only => [:delete, :undelete, :ban, :unban, :confirm_delete, :confirm_ban]
|
||||
before_filter :admin_only, :only => [:expunge]
|
||||
rescue_from ::PostFlag::Error, :with => :rescue_exception
|
||||
|
||||
@@ -27,6 +27,24 @@ module Moderator
|
||||
@post = ::Post.find(params[:id])
|
||||
@post.expunge!
|
||||
end
|
||||
|
||||
def confirm_ban
|
||||
@post = ::Post.find(params[:id])
|
||||
end
|
||||
|
||||
def ban
|
||||
@post = ::Post.find(params[:id])
|
||||
if params[:commit] == "Ban"
|
||||
@post.update_column(:is_banned, true)
|
||||
end
|
||||
redirect_to(post_path(@post), :notice => "Post was banned")
|
||||
end
|
||||
|
||||
def unban
|
||||
@post = ::Post.find(params[:id])
|
||||
@post.update_attribute(:is_banned, false)
|
||||
redirect_to(post_path(@post), :notice => "Post was unbanned")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
class PostsController < ApplicationController
|
||||
before_filter :member_only, :except => [:show, :show_seq, :index]
|
||||
before_filter :janitor_only, :only => [:ban, :unban]
|
||||
after_filter :save_recent_tags, :only => [:update]
|
||||
respond_to :html, :xml, :json
|
||||
rescue_from PostSets::SearchError, :with => :rescue_exception
|
||||
@@ -69,19 +68,6 @@ class PostsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def ban
|
||||
@post = Post.find(params[:id])
|
||||
@post.update_attribute(:is_banned, true)
|
||||
redirect_to(post_path(@post), :notice => "Post was banned")
|
||||
end
|
||||
|
||||
def unban
|
||||
@post = Post.find(params[:id])
|
||||
@post.update_attribute(:is_Banned, false)
|
||||
redirect_to(post_path(@post), :notice => "Post was unbanned")
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def tag_query
|
||||
params[:tags] || (params[:post] && params[:post][:tags])
|
||||
|
||||
@@ -92,15 +92,14 @@ class Tag < ActiveRecord::Base
|
||||
Danbooru.config.other_server_hosts.each do |host|
|
||||
delay(:queue => host).update_category_cache
|
||||
end
|
||||
|
||||
delay(:queue => "default").update_category_post_counts
|
||||
end
|
||||
|
||||
def update_category_post_counts
|
||||
Post.raw_tag_match(name).find_each do |post|
|
||||
post.reload
|
||||
post.set_tag_counts
|
||||
Post.with_timeout(10_000, nil) do
|
||||
Post.with_timeout(30_000, nil) do
|
||||
Post.raw_tag_match(name).find_each do |post|
|
||||
post.reload
|
||||
post.set_tag_counts
|
||||
post.update_column(:tag_count, post.tag_count)
|
||||
post.update_column(:tag_count_general, post.tag_count_general)
|
||||
post.update_column(:tag_count_artist, post.tag_count_artist)
|
||||
|
||||
12
app/views/moderator/post/posts/confirm_ban.html.erb
Normal file
12
app/views/moderator/post/posts/confirm_ban.html.erb
Normal file
@@ -0,0 +1,12 @@
|
||||
<h1>Ban Post</h1>
|
||||
|
||||
<div>
|
||||
<%= PostPresenter.preview(@post) %>
|
||||
</div>
|
||||
|
||||
<%= form_tag(ban_moderator_post_post_path(@post), :style => "clear: both;", :class => "simple_form") do %>
|
||||
<p>Banning a post will hide it from anyone without a gold level account or higher. You should only ban a post if an artist requested it.</p>
|
||||
|
||||
<%= submit_tag "Ban" %>
|
||||
<%= submit_tag "Cancel" %>
|
||||
<% end %>
|
||||
@@ -34,7 +34,11 @@
|
||||
Flagged
|
||||
<% end %>
|
||||
|
||||
<% if !post.is_pending? && !post.is_deleted? %>
|
||||
<% if post.is_banned? %>
|
||||
Banned
|
||||
<% end %>
|
||||
|
||||
<% if !post.is_pending? && !post.is_deleted? && !post.is_banned? %>
|
||||
Active
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if post.is_deleted? && post.flags.empty? %>
|
||||
<% if (post.is_banned? || post.is_deleted?) && post.flags.empty? %>
|
||||
<div class="ui-corner-all ui-state-highlight notice notice-deleted">
|
||||
<% if post.is_banned? %>
|
||||
This post was deleted because it was requested by the artist
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
<% end %>
|
||||
|
||||
<% if post.is_banned? %>
|
||||
<li><%= link_to "Unban", unban_post_path(post), :method => :post %></li>
|
||||
<li><%= link_to "Unban", unban_moderator_post_post_path(post), :method => :post %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Ban", ban_post_path(post), :method => :post %></li>
|
||||
<li><%= link_to "Ban", confirm_ban_moderator_post_post_path(post) %></li>
|
||||
<% end %>
|
||||
|
||||
<% if CurrentUser.is_admin? %>
|
||||
|
||||
Reference in New Issue
Block a user