diff --git a/app/controllers/plans_controller.rb b/app/controllers/plans_controller.rb index 77c5256..0026bcf 100644 --- a/app/controllers/plans_controller.rb +++ b/app/controllers/plans_controller.rb @@ -115,7 +115,7 @@ @plan = Plan.eager_load(params[:id]) authorize @plan - @visibility = @plan.visibility.blank? ? @plan.visibility.to_s : Rails.application.config.default_plan_visibility + @visibility = @plan.visibility.present? ? @plan.visibility.to_s : Rails.application.config.default_plan_visibility @editing = (!params[:editing].nil? && @plan.administerable_by?(current_user.id)) @@ -156,7 +156,7 @@ @plan = Plan.find(params[:id]) authorize @plan - @visibility = @plan.visibility.blank? ? @plan.visibility.to_s : Rails.application.config.default_plan_visibility + @visibility = @plan.visibility.present? ? @plan.visibility.to_s : Rails.application.config.default_plan_visibility # If there was no phase specified use the template's 1st phase @phase = (params[:phase].nil? ? @plan.template.phases.first : Phase.find(params[:phase])) @@ -195,9 +195,7 @@ def update @plan = Plan.find(params[:id]) authorize @plan - attrs = plan_params - attrs['visibility'] = Rails.application.config.default_plan_visibility if plan_params['visibility'].blank? respond_to do |format| if @plan.update_attributes(attrs) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a99407f..3fa1d39 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -8,8 +8,9 @@ def admin_index authorize User # Sets the user to the currently logged in user if it is undefined - @user = current_user if @user.nil? - @users = @user.org.users.includes(:roles) +# @user = current_user if @user.nil? +# @users = @user.org.users.includes(:roles) + @users = current_user.org.users.includes(:roles) end ## @@ -19,20 +20,20 @@ def admin_grant_permissions @user = User.includes(:perms).find(params[:id]) authorize @user - user_perms = @user.perms + user_perms = current_user.perms @perms = user_perms & [Perm.grant_permissions, Perm.modify_templates, Perm.modify_guidance, Perm.use_api, Perm.change_org_details] end ## # POST - updates the permissions for a user # redirects to the admin_index action - # should add validation that the perms given are current perms of the @user + # should add validation that the perms given are current perms of the current_user def admin_update_permissions @user = User.includes(:perms).find(params[:id]) authorize @user perms_ids = params[:perm_ids].blank? ? [] : params[:perm_ids].map(&:to_i) perms = Perm.where( id: perms_ids) - @user.perms.each do |perm| + current_user.perms.each do |perm| if @user.perms.include? perm if ! perms.include? perm @user.perms.delete(perm) diff --git a/app/models/answer.rb b/app/models/answer.rb index ddce6f7..f44987b 100644 --- a/app/models/answer.rb +++ b/app/models/answer.rb @@ -44,6 +44,9 @@ # @return [Answer] the saved, copied answer def self.deep_copy(answer) answer_copy = answer.dup + answer.question_options.each do |opt| + answer_copy.question_options << opt + end answer_copy.save! return answer_copy end diff --git a/app/models/plan.rb b/app/models/plan.rb index 3abf98e..ab84aca 100644 --- a/app/models/plan.rb +++ b/app/models/plan.rb @@ -32,7 +32,8 @@ :exported_plans, :project, :title, :template, :grant_number, :identifier, :principal_investigator, :principal_investigator_identifier, :description, :data_contact, :funder_name, :visibility, :exported_plans, - :roles, :users, :org, :as => [:default, :admin] + :roles, :users, :org, :data_contact_email, :data_contact_phone, + :as => [:default, :admin] accepts_nested_attributes_for :roles # public is a Ruby keyword so using publicly diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3c922a6..9b1139d 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -6,13 +6,13 @@
diff --git a/app/views/guidances/admin_index.html.erb b/app/views/guidances/admin_index.html.erb index b610abf..1d4dc80 100644 --- a/app/views/guidances/admin_index.html.erb +++ b/app/views/guidances/admin_index.html.erb @@ -75,7 +75,7 @@ <% if @guidances.length > 0 then%> - <% if @guidances.count > 10 %> + <% if @guidances.length > 10 %>
<%= render(partial: "shared/table_filter", diff --git a/app/views/orgs/shibboleth_ds.html.erb b/app/views/orgs/shibboleth_ds.html.erb index c3e2f6a..7484fdd 100644 --- a/app/views/orgs/shibboleth_ds.html.erb +++ b/app/views/orgs/shibboleth_ds.html.erb @@ -10,7 +10,7 @@ <%= _('Look up your institution here') %> - <% if @orgs.count <= 10 %> + <% if @orgs.length <= 10 %>