-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the admin new/edit views for projects after changing the form
The budget was not passed as a context variable to the form objects in the new/edit views.
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
app/controllers/concerns/decidim/budgeting_pipeline/admin/projects_controller_extensions.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module BudgetingPipeline | ||
module Admin | ||
# Customizes the admin projects controller to fix a bug on passing the | ||
# budget through the form context. | ||
module ProjectsControllerExtensions | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
def new | ||
enforce_permission_to :create, :project | ||
@form = form(Decidim::Budgets::Admin::ProjectForm).from_params( | ||
{ attachment: form(AttachmentForm).instance }, | ||
budget: budget | ||
) | ||
end | ||
|
||
def edit | ||
enforce_permission_to :update, :project, project: project | ||
@form = form(Decidim::Budgets::Admin::ProjectForm).from_model(project, budget: budget) | ||
@form.attachment = form(AttachmentForm).instance | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters