Remove mod-only user revert system (#4178).
The mass undo system from #4178 replaces this system.
Followup to f2dccf8cf.
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
class UserRevertsController < ApplicationController
|
||||
before_action :moderator_only
|
||||
|
||||
def new
|
||||
@user = User.find(params[:user_id])
|
||||
end
|
||||
|
||||
def create
|
||||
user = User.find(params[:user_id])
|
||||
revert = UserRevert.new(user.id)
|
||||
revert.process
|
||||
redirect_to(user_path(user.id))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
# reverts all changes made by a user
|
||||
class UserRevert
|
||||
THRESHOLD = 1_000
|
||||
class TooManyChangesError < RuntimeError ; end
|
||||
|
||||
attr_reader :user_id
|
||||
|
||||
def initialize(user_id)
|
||||
@user_id = user_id
|
||||
end
|
||||
|
||||
def process
|
||||
validate!
|
||||
revert_post_changes
|
||||
end
|
||||
|
||||
def validate!
|
||||
if PostArchive.where(updater_id: user_id).count > THRESHOLD
|
||||
raise TooManyChangesError.new("This user has too many changes to be reverted")
|
||||
end
|
||||
end
|
||||
|
||||
def revert_post_changes
|
||||
PostArchive.where(updater_id: user_id).find_each do |x|
|
||||
x.undo!
|
||||
end
|
||||
end
|
||||
|
||||
def self.can_revert?(user)
|
||||
user.post_update_count <= THRESHOLD
|
||||
end
|
||||
end
|
||||
@@ -101,7 +101,7 @@ class UserPresenter
|
||||
end
|
||||
|
||||
def post_version_count(template)
|
||||
template.link_to(user.post_update_count, template.post_versions_path(:lr => user.id, :search => {:updater_id => user.id}))
|
||||
template.link_to(user.post_update_count, template.post_versions_path(:search => {:updater_id => user.id}))
|
||||
end
|
||||
|
||||
def note_version_count(template)
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
<%= render "standard_listing" %>
|
||||
<% end %>
|
||||
|
||||
<% if params[:lr] && CurrentUser.is_moderator? %>
|
||||
<p><%= link_to "Revert this user's changes", new_user_revert_path(:user_id => params[:lr]) %></p>
|
||||
<% end %>
|
||||
|
||||
<%= numbered_paginator(@post_versions) %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -78,7 +78,6 @@
|
||||
<% if Danbooru.config.reportbooru_server %>
|
||||
<li><%= link_to("Top Searches", searches_explore_posts_path) %></li>
|
||||
<li><%= link_to("Missed Searches", missed_searches_explore_posts_path) %></li>
|
||||
<li><%= link_to("Post Changes", reports_post_versions_path) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
<div id="c-user-reverts">
|
||||
<div id="a-new">
|
||||
<h1>Revert Changes</h1>
|
||||
|
||||
<p>You are about to revert all changes made by <%= link_to_user @user %>. Continue?</p>
|
||||
|
||||
<%= form_tag(user_revert_path) do %>
|
||||
<%= hidden_field_tag :user_id, params[:user_id] %>
|
||||
|
||||
<%= submit_tag "Yes" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "users/secondary_links" %>
|
||||
@@ -94,9 +94,6 @@
|
||||
<th>Post Changes</th>
|
||||
<td>
|
||||
<%= presenter.post_version_count(self) %>
|
||||
<% if CurrentUser.is_moderator? && UserRevert.can_revert?(user)%>
|
||||
(<%= link_to "revert all", new_user_revert_path(user_id: user.id) %>)
|
||||
<% end %>
|
||||
<% if CurrentUser.id == user.id %>
|
||||
(<%= link_to "refresh", new_maintenance_user_count_fixes_path %>)
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user