fixes #2190
This commit is contained in:
3
app/assets/javascripts/bulk_update_requests.js.coffee
Normal file
3
app/assets/javascripts/bulk_update_requests.js.coffee
Normal file
@@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
||||
3
app/assets/stylesheets/bulk_update_requests.css.scss
Normal file
3
app/assets/stylesheets/bulk_update_requests.css.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the BulkUpdateRequests controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
31
app/controllers/bulk_update_requests_controller.rb
Normal file
31
app/controllers/bulk_update_requests_controller.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
class BulkUpdateRequestsController < ApplicationController
|
||||
respond_to :html
|
||||
before_filter :member_only
|
||||
before_filter :admin_only, :only => [:update]
|
||||
|
||||
def new
|
||||
@bulk_update_request = BulkUpdateRequest.new(:user_id => CurrentUser.user.id)
|
||||
respond_with(@bulk_update_request)
|
||||
end
|
||||
|
||||
def create
|
||||
@bulk_update_request = BulkUpdateRequest.create(params[:bulk_update_request])
|
||||
respond_with(@bulk_update_request, :location => bulk_update_requests_path)
|
||||
end
|
||||
|
||||
def update
|
||||
@bulk_update_request = BulkUpdateRequest.find(params[:id])
|
||||
if params[:status] == "approved"
|
||||
@bulk_update_request.approve!
|
||||
else
|
||||
@bulk_update_request.reject!
|
||||
end
|
||||
flash[:notice] = "Bulk update request updated"
|
||||
respond_with(@bulk_update_request, :location => bulk_update_requests_path)
|
||||
end
|
||||
|
||||
def index
|
||||
@bulk_update_requests = BulkUpdateRequest.paginate(params[:page])
|
||||
respond_with(@bulk_update_requests)
|
||||
end
|
||||
end
|
||||
2
app/helpers/bulk_update_requests_helper.rb
Normal file
2
app/helpers/bulk_update_requests_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module BulkUpdateRequestsHelper
|
||||
end
|
||||
24
app/models/bulk_update_request.rb
Normal file
24
app/models/bulk_update_request.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
class BulkUpdateRequest < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :forum_topic
|
||||
|
||||
validates_presence_of :user
|
||||
validates_inclusion_of :status, :in => %w(pending approved rejected)
|
||||
attr_accessible :user_id, :forum_topic_id, :script
|
||||
attr_accessible :status, :as => [:admin]
|
||||
before_validation :initialize_attributes, :on => :create
|
||||
|
||||
def approve!
|
||||
AliasAndImplicationImporter.new(script, forum_topic_id, "1").process!
|
||||
update_attribute(:status, "approved")
|
||||
end
|
||||
|
||||
def reject!
|
||||
update_attribute(:status, "rejected")
|
||||
end
|
||||
|
||||
def initialize_attributes
|
||||
self.user_id = CurrentUser.user.id unless self.user_id
|
||||
self.status = "pending"
|
||||
end
|
||||
end
|
||||
@@ -10,6 +10,7 @@ remove alias aaa -> bbb
|
||||
remove implication aaa -> bbb
|
||||
create alias aaa -> bbb
|
||||
create implication aaa -> bbb
|
||||
mass update aaa -> bbb
|
||||
</pre>
|
||||
|
||||
<div class="input">
|
||||
|
||||
6
app/views/bulk_update_requests/_secondary_links.html.erb
Normal file
6
app/views/bulk_update_requests/_secondary_links.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<menu>
|
||||
<li><%= link_to "Listing", bulk_update_requests_path %></li>
|
||||
<li><%= link_to "New", new_bulk_update_request_path %></li>
|
||||
</menu>
|
||||
<% end %>
|
||||
39
app/views/bulk_update_requests/index.html.erb
Normal file
39
app/views/bulk_update_requests/index.html.erb
Normal file
@@ -0,0 +1,39 @@
|
||||
<div class="bans">
|
||||
<div class="index">
|
||||
<h1>Bulk Update Requests</h1>
|
||||
|
||||
<table class="striped" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Creator</th>
|
||||
<th>Script</th>
|
||||
<th>Status</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @bulk_update_requests.each do |request| %>
|
||||
<tr id="request-<%= request.id %>">
|
||||
<td><%= link_to_user(request.user) %></td>
|
||||
<td><%= request.script %></td>
|
||||
<td><%= request.status %></td>
|
||||
<td>
|
||||
<% if CurrentUser.is_moderator? && request.status == "pending" %>
|
||||
<%= link_to "Approve", bulk_update_request_path(request, :status => "approved"), :method => :put %>
|
||||
| <%= link_to "Reject", bulk_update_request_path(request, :status => "rejected"), :method => :put %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= numbered_paginator(@bulk_update_requests) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Bulk Update Requests - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
29
app/views/bulk_update_requests/new.html.erb
Normal file
29
app/views/bulk_update_requests/new.html.erb
Normal file
@@ -0,0 +1,29 @@
|
||||
<div class="bulk-update-requests">
|
||||
<div class="new">
|
||||
<h1>New Bulk Update Request</h1>
|
||||
<%= simple_form_for(@bulk_update_request) do |f| %>
|
||||
<%= error_messages_for("bulk_update_request") %>
|
||||
|
||||
<pre>
|
||||
Use the following format:
|
||||
|
||||
remove alias aaa -> bbb
|
||||
remove implication aaa -> bbb
|
||||
create alias aaa -> bbb
|
||||
create implication aaa -> bbb
|
||||
mass update aaa -> bbb
|
||||
</pre>
|
||||
|
||||
<%= f.input :script, :as => :text %>
|
||||
<%= f.input :forum_topic_id %>
|
||||
<%= f.button :submit, :value => "Submit" %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
New Bulk Update Request - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
@@ -106,18 +106,19 @@
|
||||
<li><h1>Admin</h1></li>
|
||||
<li><%= link_to("Mod Actions", mod_actions_path) %></li>
|
||||
<li><%= link_to("Jobs", delayed_jobs_path) %></li>
|
||||
<li><%= link_to("Bulk Update Requests", new_bulk_update_request_path) %></li>
|
||||
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<li><%= link_to("Janitor Trials", janitor_trials_path) %></li>
|
||||
<li><%= link_to("IP Bans", ip_bans_path) %></li>
|
||||
<li><%= link_to("News Updates", news_updates_path) %></li>
|
||||
<li><%= link_to("Alias & Implication Import", new_admin_alias_and_implication_import_path) %></li>
|
||||
<% end %>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<li><%= link_to("Janitor Trials", janitor_trials_path) %></li>
|
||||
<li><%= link_to("IP Bans", ip_bans_path) %></li>
|
||||
<li><%= link_to("News Updates", news_updates_path) %></li>
|
||||
<li><%= link_to("Alias & Implication Import", new_admin_alias_and_implication_import_path) %></li>
|
||||
<% end %>
|
||||
|
||||
<% if Danbooru.config.is_user_advertiser?(CurrentUser.user) %>
|
||||
<li><%= link_to("Advertisements", advertisements_path) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% if Danbooru.config.is_user_advertiser?(CurrentUser.user) %>
|
||||
<li><%= link_to("Advertisements", advertisements_path) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user