Add select to Legislation::Proposals

Add admin interface for mark any proposal as selected
Add filter to public interface for selected proposals
This commit is contained in:
Raúl Fuentes
2018-08-08 10:57:42 +02:00
committed by Javi Martín
parent 429fbc5ed5
commit 05340e423c
14 changed files with 114 additions and 2 deletions

View File

@@ -1,7 +1,23 @@
class Admin::Legislation::ProposalsController < Admin::Legislation::BaseController
has_orders %w{id title supports}, only: :index
load_and_authorize_resource :process, class: "Legislation::Process"
load_and_authorize_resource :proposal, class: "Legislation::Proposal", through: :process
def index
@proposals = @proposals.send("sort_by_#{@current_order}").page(params[:page])
end
end
def update
@proposal.selected = !@proposal.selected
if @proposal.save
notice = t('admin.legislation.proposals.update.notice')
else
notice = t('admin.legislation.proposals.update.error')
end
redirect_to admin_legislation_process_proposals_path, notice: notice
end
end