diff --git a/app/controllers/admin/budget_investment_audits_controller.rb b/app/controllers/admin/budget_investment_audits_controller.rb
new file mode 100644
index 000000000..ec38952a6
--- /dev/null
+++ b/app/controllers/admin/budget_investment_audits_controller.rb
@@ -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
diff --git a/app/controllers/admin/budget_investments_controller.rb b/app/controllers/admin/budget_investments_controller.rb
index 0f3ed3e6a..c90c4f8e9 100644
--- a/app/controllers/admin/budget_investments_controller.rb
+++ b/app/controllers/admin/budget_investments_controller.rb
@@ -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
diff --git a/app/models/audit.rb b/app/models/audit.rb
new file mode 100644
index 000000000..9cc175a63
--- /dev/null
+++ b/app/models/audit.rb
@@ -0,0 +1,2 @@
+class Audit < Audited::Audit
+end
diff --git a/app/views/admin/audits/_audits.html.erb b/app/views/admin/audits/_audits.html.erb
index a00b1fa88..672abd93e 100644
--- a/app/views/admin/audits/_audits.html.erb
+++ b/app/views/admin/audits/_audits.html.erb
@@ -35,7 +35,7 @@
<%= link_to t("shared.show"),
- admin_audit_path(audit),
+ polymorphic_path([:admin, *resource_hierarchy_for(audit)]),
class: "button hollow primary" %>
|
diff --git a/config/initializers/audited.rb b/config/initializers/audited.rb
new file mode 100644
index 000000000..74ad9b5a3
--- /dev/null
+++ b/config/initializers/audited.rb
@@ -0,0 +1,3 @@
+Audited.config do |config|
+ config.audit_class = ::Audit
+end
diff --git a/config/initializers/routes_hierarchy.rb b/config/initializers/routes_hierarchy.rb
index 82b99cf2d..c98f3b123 100644
--- a/config/initializers/routes_hierarchy.rb
+++ b/config/initializers/routes_hierarchy.rb
@@ -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"
diff --git a/config/routes/admin.rb b/config/routes/admin.rb
index ea37989d0..d28093d52 100644
--- a/config/routes/admin.rb
+++ b/config/routes/admin.rb
@@ -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]