* feat: add tech_menu_items to the admin helper * feat: add the tech resources to /admin if the user has the correct role * feat: use a partial that will show the data update scripts in the navbar with the correct role * chore: use a method * test: chore * feat: setup the data to need permission single_resource_admin with DataUpdateScript permissions * chore: remove the if current_user.tech_admin? * chore: remove line * feat: add a DUS for single_resource_admin roles to be added to users with tech_admin roles * fix: move all teh routes outside of the block where tech_admin is required. * chore: use the constant and remove the method * chore: add a comma * Update config/routes.rb Co-authored-by: rhymes <rhymes@hey.com> * feat: add a tech admin role to the dropdown * feat: add the tech admin role along with single_resource_admin * chore: oops * refactor: amend the spec to use let blocks Co-authored-by: rhymes <rhymes@hey.com>
26 lines
633 B
Ruby
26 lines
633 B
Ruby
module Admin
|
|
class DataUpdateScriptsController < Admin::ApplicationController
|
|
layout "admin"
|
|
|
|
def index
|
|
@data_update_scripts = DataUpdateScript.order(run_at: :desc)
|
|
end
|
|
|
|
def show
|
|
response = DataUpdateScript.find(params[:id])
|
|
render json: { response: response }
|
|
rescue ActiveRecord::RecordNotFound => e
|
|
render json: { error: "#{e.class}: #{e.message}" }, status: :not_found
|
|
end
|
|
|
|
def force_run
|
|
DataUpdateWorker.perform_async(params[:id])
|
|
end
|
|
|
|
private
|
|
|
|
def authorize_admin
|
|
authorize DataUpdateScript, :access?, policy_class: InternalPolicy
|
|
end
|
|
end
|
|
end
|