This is consistent to what we usually do. Also, we're applying the same
criteria mentioned in commit 72704d776:
> We're also making these actions idempotent, so sending many requests
> to the same action will get the same result, which wasn't the case
> with the `toggle` action. Although it's a low probability case, the
> `toggle` action could result in [selecting a proposal] when trying to
> [deselect] it if someone else has [deselected it] it between the time
> the page loaded and the time the admin clicked on the "[Selected]"
> button.
23 lines
578 B
Ruby
23 lines
578 B
Ruby
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
|
|
|
|
def select
|
|
@proposal.update!(selected: true)
|
|
|
|
render :toggle_selection
|
|
end
|
|
|
|
def deselect
|
|
@proposal.update!(selected: false)
|
|
|
|
render :toggle_selection
|
|
end
|
|
end
|