Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions app/controllers/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ def show
else
Rails.configuration.x.plans.default_visibility
end

# Get all of the available funders
@funders = Org.funder
.includes(identifiers: :identifier_scheme)
.joins(:templates)
.where(templates: { published: true }).uniq.sort_by(&:name)
# TODO: Seems strange to do this. Why are we just not using an `edit` route?
@editing = (!params[:editing].nil? && @plan.administerable_by?(current_user.id))

Expand Down Expand Up @@ -261,8 +265,12 @@ def update

# TODO: For some reason the `fields_for` isn't adding the
# appropriate namespace, so org_id represents our funder
funder = org_from_params(params_in: attrs, allow_create: true)
funder_attrs = plan_params[:funder]
funder_attrs[:org_id] = plan_params[:funder][:id]
funder = org_from_params(params_in: funder_attrs, allow_create: true)
@plan.funder_id = funder&.id
attrs.delete(:funder)

process_grant(grant_params: plan_params[:grant])
attrs.delete(:grant)
attrs = remove_org_selection_params(params_in: attrs)
Expand Down
20 changes: 10 additions & 10 deletions app/views/plans/_project_details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,16 @@ ethics_report_tooltip = _("Link to a protocol from a meeting with an ethics comm
<conditional>
<div id="funder-org-controls" class="form-group">
<div class="col-md-8">
<%= fields_for :funder, plan.funder do |funder_fields| %>
<%= render partial: org_partial,
locals: {
form: form,
orgs: orgs,
funder_only: true,
label: _("Funder"),
default_org: plan.funder,
required: false
} %>
<%= form.fields_for :funder, Org.new do |funder_fields| %>
<%= render partial: "shared/org_selectors/local_only",
locals: {
form: funder_fields,
id_field: :id,
label: _("Funder"),
default_org: plan.funder,
orgs: @funders,
required: false
} %>
<% end %>
</div>
</div>
Expand Down