Merge pull request #2353 from consul/2339-admin_budgets_phases
Allow admins to edit Budget phases
This commit is contained in:
26
app/controllers/admin/budget_phases_controller.rb
Normal file
26
app/controllers/admin/budget_phases_controller.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
class Admin::BudgetPhasesController < Admin::BaseController
|
||||
|
||||
before_action :load_phase, only: [:edit, :update]
|
||||
|
||||
def edit; end
|
||||
|
||||
def update
|
||||
if @phase.update(budget_phase_params)
|
||||
redirect_to edit_admin_budget_path(@phase.budget), notice: t("flash.actions.save_changes.notice")
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_phase
|
||||
@phase = Budget::Phase.find(params[:id])
|
||||
end
|
||||
|
||||
def budget_phase_params
|
||||
valid_attributes = [:starts_at, :ends_at, :summary, :description, :enabled]
|
||||
params.require(:budget_phase).permit(*valid_attributes)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user