Merge branch 'master' into content_blocks_for_headings
This commit is contained in:
@@ -33,7 +33,7 @@ class Admin::BudgetHeadingsController < Admin::BaseController
|
||||
private
|
||||
|
||||
def budget_heading_params
|
||||
params.require(:budget_heading).permit(:name, :price, :population, :allow_custom_content)
|
||||
params.require(:budget_heading).permit(:name, :price, :population, :allow_custom_content, :latitude, :longitude)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,76 +1,8 @@
|
||||
class Admin::BudgetInvestmentMilestonesController < Admin::BaseController
|
||||
include Translatable
|
||||
|
||||
before_action :load_budget_investment, only: [:index, :new, :create, :edit, :update, :destroy]
|
||||
before_action :load_budget_investment_milestone, only: [:edit, :update, :destroy]
|
||||
before_action :load_statuses, only: [:index, :new, :create, :edit, :update]
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def new
|
||||
@milestone = Budget::Investment::Milestone.new
|
||||
end
|
||||
|
||||
def create
|
||||
@milestone = Budget::Investment::Milestone.new(milestone_params)
|
||||
@milestone.investment = @investment
|
||||
if @milestone.save
|
||||
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment),
|
||||
notice: t('admin.milestones.create.notice')
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @milestone.update(milestone_params)
|
||||
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment),
|
||||
notice: t('admin.milestones.update.notice')
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@milestone.destroy
|
||||
redirect_to admin_budget_budget_investment_path(@investment.budget, @investment),
|
||||
notice: t('admin.milestones.delete.notice')
|
||||
end
|
||||
class Admin::BudgetInvestmentMilestonesController < Admin::MilestonesController
|
||||
|
||||
private
|
||||
|
||||
def milestone_params
|
||||
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
attributes = [:publication_date, :budget_investment_id, :status_id,
|
||||
translation_params(Budget::Investment::Milestone),
|
||||
image_attributes: image_attributes, documents_attributes: documents_attributes]
|
||||
|
||||
params.require(:budget_investment_milestone).permit(*attributes)
|
||||
def milestoneable
|
||||
Budget::Investment.find(params[:budget_investment_id])
|
||||
end
|
||||
|
||||
def load_budget_investment
|
||||
@investment = Budget::Investment.find(params[:budget_investment_id])
|
||||
end
|
||||
|
||||
def load_budget_investment_milestone
|
||||
@milestone = get_milestone
|
||||
end
|
||||
|
||||
def get_milestone
|
||||
Budget::Investment::Milestone.find(params[:id])
|
||||
end
|
||||
|
||||
def resource
|
||||
get_milestone
|
||||
end
|
||||
|
||||
def load_statuses
|
||||
@statuses = Budget::Investment::Status.all
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Admin::ProposalsController < Admin::BaseController
|
||||
class Admin::HiddenProposalsController < Admin::BaseController
|
||||
include FeatureFlags
|
||||
|
||||
has_filters %w{without_confirmed_hide all with_confirmed_hide}, only: :index
|
||||
has_filters %w[without_confirmed_hide all with_confirmed_hide], only: :index
|
||||
|
||||
feature_flag :proposals
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
class Admin::BudgetInvestmentStatusesController < Admin::BaseController
|
||||
class Admin::MilestoneStatusesController < Admin::BaseController
|
||||
|
||||
before_action :load_status, only: [:edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
@statuses = Budget::Investment::Status.all
|
||||
@statuses = Milestone::Status.all
|
||||
end
|
||||
|
||||
def new
|
||||
@status = Budget::Investment::Status.new
|
||||
@status = Milestone::Status.new
|
||||
end
|
||||
|
||||
def create
|
||||
@status = Budget::Investment::Status.new(status_params)
|
||||
@status = Milestone::Status.new(status_params)
|
||||
|
||||
if @status.save
|
||||
redirect_to admin_budget_investment_statuses_path,
|
||||
redirect_to admin_milestone_statuses_path,
|
||||
notice: t('admin.statuses.create.notice')
|
||||
else
|
||||
render :new
|
||||
@@ -26,7 +26,7 @@ class Admin::BudgetInvestmentStatusesController < Admin::BaseController
|
||||
|
||||
def update
|
||||
if @status.update(status_params)
|
||||
redirect_to admin_budget_investment_statuses_path,
|
||||
redirect_to admin_milestone_statuses_path,
|
||||
notice: t('admin.statuses.update.notice')
|
||||
else
|
||||
render :edit
|
||||
@@ -35,17 +35,17 @@ class Admin::BudgetInvestmentStatusesController < Admin::BaseController
|
||||
|
||||
def destroy
|
||||
@status.destroy
|
||||
redirect_to admin_budget_investment_statuses_path,
|
||||
redirect_to admin_milestone_statuses_path,
|
||||
notice: t('admin.statuses.delete.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_status
|
||||
@status = Budget::Investment::Status.find(params[:id])
|
||||
@status = Milestone::Status.find(params[:id])
|
||||
end
|
||||
|
||||
def status_params
|
||||
params.require(:budget_investment_status).permit([:name, :description])
|
||||
params.require(:milestone_status).permit([:name, :description])
|
||||
end
|
||||
end
|
||||
72
app/controllers/admin/milestones_controller.rb
Normal file
72
app/controllers/admin/milestones_controller.rb
Normal file
@@ -0,0 +1,72 @@
|
||||
class Admin::MilestonesController < Admin::BaseController
|
||||
include Translatable
|
||||
|
||||
before_action :load_milestoneable, only: [:index, :new, :create, :edit, :update, :destroy]
|
||||
before_action :load_milestone, only: [:edit, :update, :destroy]
|
||||
before_action :load_statuses, only: [:index, :new, :create, :edit, :update]
|
||||
helper_method :milestoneable_path
|
||||
|
||||
def index
|
||||
end
|
||||
|
||||
def new
|
||||
@milestone = @milestoneable.milestones.new
|
||||
end
|
||||
|
||||
def create
|
||||
@milestone = @milestoneable.milestones.new(milestone_params)
|
||||
if @milestone.save
|
||||
redirect_to milestoneable_path, notice: t('admin.milestones.create.notice')
|
||||
else
|
||||
render :new
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
if @milestone.update(milestone_params)
|
||||
redirect_to milestoneable_path, notice: t('admin.milestones.update.notice')
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@milestone.destroy
|
||||
redirect_to milestoneable_path, notice: t('admin.milestones.delete.notice')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def milestone_params
|
||||
image_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
documents_attributes = [:id, :title, :attachment, :cached_attachment, :user_id, :_destroy]
|
||||
attributes = [:publication_date, :status_id,
|
||||
translation_params(Milestone),
|
||||
image_attributes: image_attributes, documents_attributes: documents_attributes]
|
||||
|
||||
params.require(:milestone).permit(*attributes)
|
||||
end
|
||||
|
||||
def load_milestoneable
|
||||
@milestoneable = milestoneable
|
||||
end
|
||||
|
||||
def milestoneable
|
||||
raise "Implement in subclass"
|
||||
end
|
||||
|
||||
def load_milestone
|
||||
@milestone = @milestoneable.milestones.find(params[:id])
|
||||
end
|
||||
|
||||
def load_statuses
|
||||
@statuses = Milestone::Status.all
|
||||
end
|
||||
|
||||
def milestoneable_path
|
||||
polymorphic_path([:admin, *resource_hierarchy_for(@milestone.milestoneable)])
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user