add homepage for legislation processes
This commit is contained in:
36
app/controllers/admin/legislation/homepages_controller.rb
Normal file
36
app/controllers/admin/legislation/homepages_controller.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
class Admin::Legislation::HomepagesController < Admin::Legislation::BaseController
|
||||
include Translatable
|
||||
|
||||
load_and_authorize_resource :process, class: "Legislation::Process"
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @process.update(process_params)
|
||||
link = legislation_process_path(@process).html_safe
|
||||
redirect_to :back, notice: t('admin.legislation.processes.update.notice', link: link)
|
||||
else
|
||||
flash.now[:error] = t('admin.legislation.processes.update.error')
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def process_params
|
||||
params.require(:legislation_process).permit(allowed_params)
|
||||
end
|
||||
|
||||
def allowed_params
|
||||
[
|
||||
:homepage,
|
||||
:homepage_enabled,
|
||||
translation_params(::Legislation::Process)
|
||||
]
|
||||
end
|
||||
|
||||
def resource
|
||||
@process || ::Legislation::Process.find(params[:id])
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user