From a0fe31479fcdf5af741a7fa02305b8c3aab6656d Mon Sep 17 00:00:00 2001 From: Jure Grabnar Date: Tue, 9 Aug 2016 10:00:44 +0200 Subject: [PATCH] Fix permissions for archived experiments --- app/helpers/permission_helper.rb | 11 +++- app/views/experiments/canvas.html.erb | 50 ++++++++++--------- .../experiment_archive/_experiment.html.erb | 3 +- 3 files changed, 37 insertions(+), 27 deletions(-) diff --git a/app/helpers/permission_helper.rb b/app/helpers/permission_helper.rb index a76f00d9c..2755551d5 100644 --- a/app/helpers/permission_helper.rb +++ b/app/helpers/permission_helper.rb @@ -137,7 +137,16 @@ module PermissionHelper # ---- Some things are disabled for archived experiment ---- around [ - :can_edit_experiment + :can_edit_experiment, + :can_archive_experiment, + :can_edit_canvas, + :can_reposition_modules, + :can_edit_connections, + :can_create_modules, + :can_edit_modules, + :can_edit_module_groups, + :can_clone_modules, + :can_archive_modules ] do |proxy, *args, &block| if args[0] experiment = args[0] diff --git a/app/views/experiments/canvas.html.erb b/app/views/experiments/canvas.html.erb index 6221c701c..6ec6047b5 100644 --- a/app/views/experiments/canvas.html.erb +++ b/app/views/experiments/canvas.html.erb @@ -12,7 +12,7 @@ class: "ajax btn btn-default", "data-action" => "edit" %> <% end %> - <% if can_create_experiment(@project) %> + <% if can_create_experiment(@project) && @experiment.active? %> <%= link_to t('experiments.new.create'), new_project_experiment_url(@project), remote: true, @@ -21,29 +21,31 @@ class: "btn btn-primary" %> <% end %> - - - - + <% if can_edit_experiment(@experiment) || can_archive_experiment(@experiment) %> + + + + + <% end %>
<%=link_to canvas_full_zoom_experiment_path(@experiment), remote: true, type: "button", class: "ajax btn btn-primary active", "data-action" => "full_zoom", "data-toggle" => "button", "aria-pressed" => true do %> diff --git a/app/views/projects/experiment_archive/_experiment.html.erb b/app/views/projects/experiment_archive/_experiment.html.erb index d972edd1d..f298be36b 100644 --- a/app/views/projects/experiment_archive/_experiment.html.erb +++ b/app/views/projects/experiment_archive/_experiment.html.erb @@ -19,8 +19,7 @@
-

<%= experiment.name %>

- +

<%= link_to experiment.name, canvas_experiment_path(experiment) %>