Fix permissions for archived experiments

This commit is contained in:
Jure Grabnar 2016-08-09 10:00:44 +02:00
parent 0ca5725f9b
commit a0fe31479f
3 changed files with 37 additions and 27 deletions

View file

@ -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]

View file

@ -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 %>
<!-- pexperiment actions -->
<span class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="exActionsMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="hidden-xs"><%= t'experiments.canvas.actions' %></span>
<span class="visible-xs-inline"><i class="glyphicon glyphicon-sort"></i></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="exActionsMenu">
<% if can_create_experiment(@project) %>
<li><%= link_to t('experiments.edit.label_title'),
edit_project_experiment_url(@project, @experiment),
remote: true,
type: 'button',
data: { id: @experiment.id },
id: 'edit-experiment' %></li>
<% end %>
<% if can_archive_experiment(@experiment) %>
<li><%= link_to t('experiments.archive.label_title'),
archive_experiment_url(@experiment),
type: 'button',
data: { confirm: t('experiments.canvas.archive_confirm') } %></li>
<% end %>
</ul>
</span>
<% if can_edit_experiment(@experiment) || can_archive_experiment(@experiment) %>
<span class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="exActionsMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<span class="hidden-xs"><%= t'experiments.canvas.actions' %></span>
<span class="visible-xs-inline"><i class="glyphicon glyphicon-sort"></i></span>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="exActionsMenu">
<% if can_edit_experiment(@experiment) %>
<li><%= link_to t('experiments.edit.label_title'),
edit_project_experiment_url(@project, @experiment),
remote: true,
type: 'button',
data: { id: @experiment.id },
id: 'edit-experiment' %></li>
<% end %>
<% if can_archive_experiment(@experiment) %>
<li><%= link_to t('experiments.archive.label_title'),
archive_experiment_url(@experiment),
type: 'button',
data: { confirm: t('experiments.canvas.archive_confirm') } %></li>
<% end %>
</ul>
</span>
<% end %>
<div id="zoom-level-buttons" class="btn-group pull-right" data-toggle="buttons">
<%=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 %>

View file

@ -19,8 +19,7 @@
</ul>
</div>
<h3 class="panel-title"><%= experiment.name %></h3>
<h3 class="panel-title"><%= link_to experiment.name, canvas_experiment_path(experiment) %></h3>
</div>
<div class="panel-body">