diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index a687531..3dea892 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -33,7 +33,7 @@ @plan = Plan.new authorize @plan - @plan.principal_investigator = current_user.name + @plan.principal_investigator = current_user.surname.blank? ? nil : "#{current_user.firstname} #{current_user.surname}" @plan.data_contact = current_user.email @plan.funder_name = plan_params[:funder_name] @@ -80,7 +80,7 @@ flash[:notice] = msg respond_to do |format| - format.js { render js: "window.location='#{plan_url(@plan)}'" } + format.js { render js: "window.location='#{plan_url(@plan)}?editing=true'" } end else @@ -102,7 +102,7 @@ @editing = (!params[:editing].nil? && @plan.administerable_by?(current_user.id)) @all_guidance_groups = @plan.get_guidance_group_options @selected_guidance_groups = @plan.guidance_groups.pluck(:id) - @based_on = @plan.base_template + @based_on = (@plan.template.customization_of.nil? ? @plan.template : Template.live(@plan.template.customization_of)) respond_to :html end diff --git a/app/models/plan.rb b/app/models/plan.rb index 8a01638..8c8d3c7 100644 --- a/app/models/plan.rb +++ b/app/models/plan.rb @@ -1111,8 +1111,8 @@ # -------------------------------------------------------- def set_creation_defaults # Only run this before_validation because rails fires this before save/create - if self.id.nil? - self.title = "My plan (#{self.template.title})" if self.title.nil? + if self.id.nil? + self.title = "My plan (#{self.template.title})" if self.title.nil? && !self.template.nil? self.visibility = 1 end end diff --git a/app/views/plans/_available_templates.html.erb b/app/views/plans/_available_templates.html.erb index acdd409..90c4878 100644 --- a/app/views/plans/_available_templates.html.erb +++ b/app/views/plans/_available_templates.html.erb @@ -1,10 +1,10 @@ -

<%= _('Which DMP template would you like to use?') %>

+<%= _('Which DMP template would you like to use?') %> -