diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index c7b45bb..9aafd2f 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -47,12 +47,9 @@ if !funder_id.blank? # get all funder @templates funder = Org.find(params[:plan][:funder_id]) - logger.debug "RAY: funder = " + funder.inspect @templates = get_most_recent( funder.templates.where("published = ?", true).all ) - logger.debug "RAY: found "+ @templates.count.to_s + " templates = " + @templates.inspect orgtemplates = current_user.org.templates.all - logger.debug "RAY: found "+ @templates.count.to_s + " org templates = " + @templates.inspect replacements = [] # replace any that are customised by the org @@ -62,7 +59,6 @@ replacements << orgt end @templates + replacements - logger.debug "RAY: finally "+ @templates.count.to_s + " templates = " + @templates.inspect else # get all org @templates which are not customisations @@ -113,11 +109,13 @@ # GET /plans/show def show - @plan = Plan.find(params[:id]) + @plan = Plan.includes(template: {phases: :sections} ).find(params[:id]) authorize @plan @editing = params[:editing] && @plan.administerable_by?(current_user.id) @selected_guidance_groups = [] - @selected_guidance_groups = @plan.plan_guidance_groups.map{ |pgg| [pgg.guidance_group.name, pgg.guidance_group.id, :checked => pgg.selected] } + #@selected_guidance_groups = @plan.plan_guidance_groups.map{ |pgg| [pgg.guidance_group.name, pgg.guidance_group.id, :checked => pgg.selected] } + all_guidance_groups = @plan.plan_guidance_groups.includes(:guidance_group) + @selected_guidance_groups = all_guidance_groups.map{ |pgg| [pgg.guidance_group.name, pgg.guidance_group.id, :checked => pgg.selected] } @selected_guidance_groups.sort! if user_signed_in? && @plan.readable_by?(current_user.id) then @@ -196,18 +194,12 @@ def update_guidance_choices - logger.debug "RAY: update_guidance_choices with params" - logger.debug params.inspect - @plan = Plan.find(params[:id]) authorize @plan if user_signed_in? && @plan.editable_by?(current_user.id) then - guidance_ids = params[:plan][:guidances] - logger.debug "RAY: guidance ids = " + guidance_ids.inspect + guidance_ids = params[:plan][:plan_guidance_group_ids] @plan.plan_guidance_groups.each do |pgg| - logger.debug "RAY: looking at pgg = " + pgg.inspect pgg.selected = guidance_ids.include?(pgg.guidance_group_id.to_s) - logger.debug "RAY: pg now = " + pgg.inspect pgg.save! end @plan.save! diff --git a/db/schema.rb b/db/schema.rb index 81d309b..10fffcd 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -328,6 +328,7 @@ t.string "firstname" t.string "surname" t.string "email", default: "", null: false + t.string "orcid_id" t.string "shibboleth_id" t.datetime "created_at" t.datetime "updated_at"