improve bulk update req ui

This commit is contained in:
r888888888
2015-04-21 17:22:16 -07:00
parent 3a66e521fc
commit ee4c19a0dd
6 changed files with 17 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
class BulkUpdateRequestsController < ApplicationController
respond_to :html, :xml, :json
respond_to :html, :xml, :json, :js
before_filter :member_only
before_filter :admin_only, :only => [:approve]
before_filter :load_bulk_update_request, :except => [:new, :create, :index]
@@ -36,7 +36,7 @@ class BulkUpdateRequestsController < ApplicationController
def destroy
if @bulk_update_request.editable?(CurrentUser.user)
@bulk_update_request.reject!
flash[:notice] = "Bulk update request deleted"
flash[:notice] = "Bulk update request rejected"
respond_with(@bulk_update_request, :location => bulk_update_requests_path)
else
access_denied()

View File

@@ -13,6 +13,7 @@ class BulkUpdateRequest < ActiveRecord::Base
attr_accessible :user_id, :forum_topic_id, :script, :title, :reason
attr_accessible :status, :as => [:admin]
before_validation :initialize_attributes, :on => :create
before_validation :normalize_text
after_create :create_forum_topic
module SearchMethods
@@ -114,4 +115,8 @@ class BulkUpdateRequest < ActiveRecord::Base
end
end
end
def normalize_text
self.script = script.downcase
end
end

View File

@@ -14,13 +14,13 @@
<td><%= link_to_user(request.user) %></td>
<td><%= link_to(request.forum_topic_id, forum_topic_path(request.forum_topic_id)) %></td>
<td><%= script_with_line_breaks(request.script) %></td>
<td><%= request.status %></td>
<td id="request-status-for-<%= request.id %>"><%= request.status %></td>
<td>
<% if CurrentUser.is_moderator? && request.status == "pending" %>
<%= link_to "Approve", approve_bulk_update_request_path(request), :method => :post %> |
<%= link_to "Approve", approve_bulk_update_request_path(request), :remote => true, :method => :post %> |
<% end %>
<% if request.editable?(CurrentUser.user) %>
<%= link_to "Delete", bulk_update_request_path(request), :method => :delete, :data => {:confirm => "Are you sure you want to delete this bulk update request?"} %> |
<%= link_to "Delete", bulk_update_request_path(request), :method => :delete, :remote => true, :data => {:confirm => "Are you sure you want to delete this bulk update request?"} %> |
<%= link_to "Edit", edit_bulk_update_request_path(request) %>
<% end %>
</td>

View File

@@ -0,0 +1 @@
$("#request-status-for-<%= @bulk_update_request.id %>").html("queued");

View File

@@ -0,0 +1 @@
$("#request-status-for-<%= @bulk_update_request.id %>").html("rejected");

View File

@@ -20,7 +20,11 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
setup do
@admin = FactoryGirl.create(:admin_user)
@topic = FactoryGirl.create(:forum_topic)
@req = FactoryGirl.create(:bulk_update_request, :script => "create alias aaa -> bbb", :forum_topic => @topic)
@req = FactoryGirl.create(:bulk_update_request, :script => "create alias AAA -> BBB", :forum_topic => @topic)
end
should "downcase the text" do
assert_equal("create alias aaa -> bbb", @req.script)
end
should "update the topic when processed" do