diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin_censor_rule_controller.rb | 24 | ||||
-rw-r--r-- | app/views/admin_censor_rule/_show.html.erb | 4 | ||||
-rw-r--r-- | app/views/admin_censor_rule/edit.html.erb | 5 | ||||
-rw-r--r-- | app/views/admin_censor_rule/new.html.erb | 1 |
4 files changed, 12 insertions, 22 deletions
diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb index 01c0bf4b2..c82aa342c 100644 --- a/app/controllers/admin_censor_rule_controller.rb +++ b/app/controllers/admin_censor_rule_controller.rb @@ -5,11 +5,12 @@ # Email: hello@mysociety.org; WWW: http://www.mysociety.org/ class AdminCensorRuleController < AdminController + def new - if params[:info_request_id] - @info_request = InfoRequest.find(params[:info_request_id]) + if params[:request_id] + @info_request = InfoRequest.find(params[:request_id]) @censor_rule = @info_request.censor_rules.build - @form_url = admin_info_request_censor_rules_path(@info_request) + @form_url = admin_request_censor_rules_path(@info_request) end if params[:user_id] @@ -17,18 +18,14 @@ class AdminCensorRuleController < AdminController @censor_rule = @censor_user.censor_rules.build @form_url = admin_user_censor_rules_path(@censor_user) end - - @censor_rule ||= CensorRule.new - @form_url ||= admin_rule_create_path end def create params[:censor_rule][:last_edit_editor] = admin_current_user - - if params[:info_request_id] - @info_request = InfoRequest.find(params[:info_request_id]) + if params[:request_id] + @info_request = InfoRequest.find(params[:request_id]) @censor_rule = @info_request.censor_rules.build(params[:censor_rule]) - @form_url = admin_info_request_censor_rules_path(@info_request) + @form_url = admin_request_censor_rules_path(@info_request) end if params[:user_id] @@ -37,9 +34,6 @@ class AdminCensorRuleController < AdminController @form_url = admin_user_censor_rules_path(@censor_user) end - @censor_rule ||= CensorRule.new(params[:censor_rule]) - @form_url ||= admin_rule_create_path - if @censor_rule.save if !@censor_rule.info_request.nil? expire_for_request(@censor_rule.info_request) @@ -55,8 +49,6 @@ class AdminCensorRuleController < AdminController redirect_to admin_request_url(@censor_rule.info_request) elsif !@censor_rule.user.nil? redirect_to admin_user_url(@censor_rule.user) - else - raise "internal error" end else render :action => 'new' @@ -95,7 +87,7 @@ class AdminCensorRuleController < AdminController end def destroy - @censor_rule = CensorRule.find(params[:censor_rule_id]) + @censor_rule = CensorRule.find(params[:id]) info_request = @censor_rule.info_request user = @censor_rule.user diff --git a/app/views/admin_censor_rule/_show.html.erb b/app/views/admin_censor_rule/_show.html.erb index 46904b3b9..4b37d0cc9 100644 --- a/app/views/admin_censor_rule/_show.html.erb +++ b/app/views/admin_censor_rule/_show.html.erb @@ -15,7 +15,7 @@ <td><%=h censor_rule.send(column) %></td> <% end %> <td> - <%= link_to "Edit", admin_rule_edit_path(censor_rule) %> + <%= link_to "Edit", edit_admin_censor_rule_path(censor_rule) %> </td> </tr> <% end %> @@ -25,7 +25,7 @@ <% end %> <% if defined? info_request %> - <%= link_to "New censor rule", new_admin_info_request_censor_rule_path(info_request), :class => "btn btn-info" %> + <%= link_to "New censor rule", new_admin_request_censor_rule_path(info_request), :class => "btn btn-info" %> <span class="label label-info">for this request only</span> <% end %> diff --git a/app/views/admin_censor_rule/edit.html.erb b/app/views/admin_censor_rule/edit.html.erb index 230446ed3..ff07987f2 100644 --- a/app/views/admin_censor_rule/edit.html.erb +++ b/app/views/admin_censor_rule/edit.html.erb @@ -2,15 +2,14 @@ <h1><%=@title%></h1> -<%= form_tag admin_rule_update_path(@censor_rule), :class => "form form-horizontal" do %> +<%= form_tag admin_censor_rule_path(@censor_rule), :method => 'put', :class => "form form-horizontal" do %> <%= render :partial => 'form', :locals => { :info_request => @censor_rule.info_request, :user => @censor_rule.user } %> <div class="form-actions"> <%= submit_tag 'Save', :accesskey => 's', :class => "btn btn-primary" %> </div> <% end %> -<%= form_tag admin_rule_destroy_path(@censor_rule), :class => "form form-horizontal" do %> - <%= hidden_field_tag(:censor_rule_id, @censor_rule.id) %> +<%= form_tag admin_censor_rule_path(@censor_rule), :method => 'delete', :class => "form form-horizontal" do %> <div class="form-actions"> Permanent! --> <%= submit_tag "Destroy rule", :class => "btn btn-primary" %> </div> diff --git a/app/views/admin_censor_rule/new.html.erb b/app/views/admin_censor_rule/new.html.erb index 26b3212be..ded31cff2 100644 --- a/app/views/admin_censor_rule/new.html.erb +++ b/app/views/admin_censor_rule/new.html.erb @@ -4,7 +4,6 @@ <%= form_for @censor_rule, :url => @form_url, :class => "form form-horizontal" do %> <%= render :partial => 'form', :locals => { :info_request => @info_request, :user => @censor_user } %> - <div class="form-actions"> <%= submit_tag "Create", :class => "btn btn-primary" %> </div> |