improve bulk update req ui
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
class BulkUpdateRequestsController < ApplicationController
|
class BulkUpdateRequestsController < ApplicationController
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json, :js
|
||||||
before_filter :member_only
|
before_filter :member_only
|
||||||
before_filter :admin_only, :only => [:approve]
|
before_filter :admin_only, :only => [:approve]
|
||||||
before_filter :load_bulk_update_request, :except => [:new, :create, :index]
|
before_filter :load_bulk_update_request, :except => [:new, :create, :index]
|
||||||
@@ -36,7 +36,7 @@ class BulkUpdateRequestsController < ApplicationController
|
|||||||
def destroy
|
def destroy
|
||||||
if @bulk_update_request.editable?(CurrentUser.user)
|
if @bulk_update_request.editable?(CurrentUser.user)
|
||||||
@bulk_update_request.reject!
|
@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)
|
respond_with(@bulk_update_request, :location => bulk_update_requests_path)
|
||||||
else
|
else
|
||||||
access_denied()
|
access_denied()
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ class BulkUpdateRequest < ActiveRecord::Base
|
|||||||
attr_accessible :user_id, :forum_topic_id, :script, :title, :reason
|
attr_accessible :user_id, :forum_topic_id, :script, :title, :reason
|
||||||
attr_accessible :status, :as => [:admin]
|
attr_accessible :status, :as => [:admin]
|
||||||
before_validation :initialize_attributes, :on => :create
|
before_validation :initialize_attributes, :on => :create
|
||||||
|
before_validation :normalize_text
|
||||||
after_create :create_forum_topic
|
after_create :create_forum_topic
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
@@ -114,4 +115,8 @@ class BulkUpdateRequest < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def normalize_text
|
||||||
|
self.script = script.downcase
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,13 +14,13 @@
|
|||||||
<td><%= link_to_user(request.user) %></td>
|
<td><%= link_to_user(request.user) %></td>
|
||||||
<td><%= link_to(request.forum_topic_id, forum_topic_path(request.forum_topic_id)) %></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><%= script_with_line_breaks(request.script) %></td>
|
||||||
<td><%= request.status %></td>
|
<td id="request-status-for-<%= request.id %>"><%= request.status %></td>
|
||||||
<td>
|
<td>
|
||||||
<% if CurrentUser.is_moderator? && request.status == "pending" %>
|
<% 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 %>
|
<% end %>
|
||||||
<% if request.editable?(CurrentUser.user) %>
|
<% 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) %>
|
<%= link_to "Edit", edit_bulk_update_request_path(request) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
1
app/views/bulk_update_requests/approve.js.erb
Normal file
1
app/views/bulk_update_requests/approve.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
$("#request-status-for-<%= @bulk_update_request.id %>").html("queued");
|
||||||
1
app/views/bulk_update_requests/destroy.js.erb
Normal file
1
app/views/bulk_update_requests/destroy.js.erb
Normal file
@@ -0,0 +1 @@
|
|||||||
|
$("#request-status-for-<%= @bulk_update_request.id %>").html("rejected");
|
||||||
@@ -20,7 +20,11 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
|||||||
setup do
|
setup do
|
||||||
@admin = FactoryGirl.create(:admin_user)
|
@admin = FactoryGirl.create(:admin_user)
|
||||||
@topic = FactoryGirl.create(:forum_topic)
|
@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
|
end
|
||||||
|
|
||||||
should "update the topic when processed" do
|
should "update the topic when processed" do
|
||||||
|
|||||||
Reference in New Issue
Block a user