Allow creating budgets step by step
We introduce the first step (creating the budget). Co-Authored-By: decabeza <alberto@decabeza.es>
This commit is contained in:
committed by
Javi Martín
parent
82e8de094b
commit
2115eb5274
@@ -6,7 +6,7 @@ class Admin::BudgetsController < Admin::BaseController
|
||||
|
||||
has_filters %w[all open finished], only: :index
|
||||
|
||||
before_action :load_budget, except: [:index, :new, :create]
|
||||
before_action :load_budget, except: [:index]
|
||||
load_and_authorize_resource
|
||||
|
||||
def index
|
||||
@@ -17,9 +17,6 @@ class Admin::BudgetsController < Admin::BaseController
|
||||
render :edit
|
||||
end
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
@@ -46,15 +43,6 @@ class Admin::BudgetsController < Admin::BaseController
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@budget = Budget.new(budget_params.merge(published: false))
|
||||
if @budget.save
|
||||
redirect_to edit_admin_budget_path(@budget), notice: t("admin.budgets.create.notice")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @budget.investments.any?
|
||||
redirect_to admin_budgets_path, alert: t("admin.budgets.destroy.unable_notice")
|
||||
|
||||
32
app/controllers/admin/budgets_wizard/budgets_controller.rb
Normal file
32
app/controllers/admin/budgets_wizard/budgets_controller.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
class Admin::BudgetsWizard::BudgetsController < Admin::BaseController
|
||||
include Translatable
|
||||
include FeatureFlags
|
||||
feature_flag :budgets
|
||||
|
||||
load_and_authorize_resource
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
def create
|
||||
@budget.published = false
|
||||
|
||||
if @budget.save
|
||||
redirect_to edit_admin_budget_path(@budget), notice: t("admin.budgets.create.notice")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def budget_params
|
||||
params.require(:budget).permit(*allowed_params)
|
||||
end
|
||||
|
||||
def allowed_params
|
||||
valid_attributes = [:currency_symbol, :voting_style, administrator_ids: [], valuator_ids: []]
|
||||
|
||||
valid_attributes + [translation_params(Budget)]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user