Skip to content

Commit

Permalink
patch to fix bug in plan creation
Browse files Browse the repository at this point in the history
  • Loading branch information
briri committed Jul 2, 2020
1 parent f413edd commit 8333b00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
16 changes: 8 additions & 8 deletions app/controllers/plans_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ def create
# plan.funder which forces the hidden id hash to be :id
# so we need to convert it to :org_id so it works with the
# OrgSelectable and OrgSelection services
if params[:org][:id].present?
attrs = params[:org]
attrs[:org_id] = attrs[:id]
@plan.org = org_from_params(params_in: attrs, allow_create: false)
org_hash = plan_params[:org] || params[:org]
if org_hash[:id].present?
org_hash[:org_id] = org_hash[:id]
@plan.org = org_from_params(params_in: org_hash, allow_create: false)
end
if params[:funder][:id].present?
attrs = params[:funder]
attrs[:org_id] = attrs[:id]
@plan.funder = org_from_params(params_in: attrs, allow_create: false)
funder_hash = plan_params[:funder] || params[:funder]
if funder_hash[:id].present?
funder_hash[:org_id] = funder_hash[:id]
@plan.funder = org_from_params(params_in: funder_hash, allow_create: false)
end

if @plan.save
Expand Down
15 changes: 10 additions & 5 deletions app/helpers/template_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,18 @@ def links_to_a_elements(links, separator = ", ")
# @param text [String] text for the link
# @param id [String] id for the link element
def direct_link(template, hidden = false, text = nil, id = nil)
params = { org_id: template.org.id, funder_id: '-1', template_id: template.id }
cls = text.nil? ? 'direct-link' : 'direct-link btn btn-default'
style = hidden ? 'display: none' : ''
params = {
org: { id: current_user&.org&.id },
funder: { id: template.org&.id },
template_id: template.id
}
cls = text.nil? ? "direct-link" : "direct-link btn btn-default"
style = hidden ? "display: none" : ""

link_to(plans_url(plan: params), method: :post, title: _('Create plan'), class: cls, id: id, style: style) do
link_to(plans_url(plan: params), method: :post, title: _("Create plan"),
class: cls, id: id, style: style) do
if text.nil?
'<span class="fa fa-plus-square"></span>'.html_safe
"<span class=\"fa fa-plus-square\"></span>".html_safe
else
text.html_safe
end
Expand Down

0 comments on commit 8333b00

Please sign in to comment.