Use a different controller for investment audits

The same way we do for milestones. We also make the code more consistent
since the view was already in a separate folder.
This commit is contained in:
Javi Martín
2019-11-03 01:05:53 +01:00
parent ed223e0bd1
commit e0c2468bd2
7 changed files with 18 additions and 9 deletions

View File

@@ -0,0 +1,8 @@
class Admin::BudgetInvestmentAuditsController < Admin::BaseController
def show
investment = Budget::Investment.find(params[:budget_investment_id])
@audit = investment.audits.find(params[:id])
render "admin/audits/show"
end
end

View File

@@ -9,7 +9,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
has_orders %w[oldest], only: [:show, :edit]
has_filters %w[all], only: [:index, :toggle_selection]
before_action :load_budget, except: :audit
before_action :load_budget
before_action :load_investment, only: [:show, :edit, :update, :toggle_selection]
before_action :load_ballot, only: [:show, :index]
before_action :parse_valuation_filters
@@ -60,11 +60,6 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
load_investments
end
def audit
@audit = Audited::Audit.find(params[:id])
render "admin/audits/show"
end
private
def load_comments

2
app/models/audit.rb Normal file
View File

@@ -0,0 +1,2 @@
class Audit < Audited::Audit
end

View File

@@ -35,7 +35,7 @@
</td>
<td>
<%= link_to t("shared.show"),
admin_audit_path(audit),
polymorphic_path([:admin, *resource_hierarchy_for(audit)]),
class: "button hollow primary" %>
</td>
</tr>

View File

@@ -0,0 +1,3 @@
Audited.config do |config|
config.audit_class = ::Audit
end

View File

@@ -13,6 +13,8 @@ module ActionDispatch::Routing::UrlFor
[*resource_hierarchy_for(resource.milestoneable), resource]
when "ProgressBar"
[*resource_hierarchy_for(resource.progressable), resource]
when "Audit"
[*resource_hierarchy_for(resource.auditable), resource]
when "Legislation::Annotation"
[resource.draft_version.process, resource.draft_version, resource]
when "Legislation::Proposal", "Legislation::Question", "Legislation::DraftVersion"

View File

@@ -63,6 +63,7 @@ namespace :admin do
resources :budget_investments, only: [:index, :show, :edit, :update] do
member { patch :toggle_selection }
resources :audits, only: :show, controller: "budget_investment_audits"
resources :milestones, controller: "budget_investment_milestones"
resources :progress_bars, except: :show, controller: "budget_investment_progress_bars"
end
@@ -250,8 +251,6 @@ namespace :admin do
get "download_settings/:resource", to: "download_settings#edit", as: "edit_download_settings"
put "download_settings/:resource", to: "download_settings#update", as: "update_download_settings"
get "/admin/audits/:id", to: "budget_investments#audit", as: "audit"
resources :local_census_records
namespace :local_census_records do
resources :imports, only: [:new, :create, :show]