Merge pull request #67 from ZmagoD/zd_SCI_337

Zd sci 337
This commit is contained in:
Zmago Devetak 2016-08-18 08:06:38 +02:00 committed by GitHub
commit f2e08db106
4 changed files with 19 additions and 15 deletions

View file

@ -80,6 +80,9 @@ class ExperimentsController < ApplicationController
@experiment.archived = true @experiment.archived = true
@experiment.archived_by = current_user @experiment.archived_by = current_user
@experiment.archived_on = DateTime.now @experiment.archived_on = DateTime.now
@experiment.my_modules.each do |my_module|
my_module.archive(current_user)
end
if @experiment.save if @experiment.save
flash[:success] = t('experiments.archive.success_flash', flash[:success] = t('experiments.archive.success_flash',
experiment: @experiment.name) experiment: @experiment.name)

View file

@ -82,20 +82,6 @@ class Experiment < ActiveRecord::Base
.distinct .distinct
end end
def assigned_modules(user)
role = self.project.user_role(user)
if role.blank?
return MyModule.none
elsif role == "owner"
return self.active_modules
else
return self.active_modules
.joins(:user_my_modules)
.where("user_my_modules.user_id IN (?)", user.id)
.distinct
end
end
def active_modules def active_modules
my_modules.where(:archived => false) my_modules.where(:archived => false)
end end

View file

@ -143,4 +143,19 @@ class Project < ActiveRecord::Base
ids.delete_if { |i| i.flatten.empty? } ids.delete_if { |i| i.flatten.empty? }
ids.join(', ') ids.join(', ')
end end
def assigned_modules(user)
role = user_role(user)
if role.blank?
MyModule.none
elsif role == 'owner'
project_my_modules.where(archived: false)
else
project_my_modules
.joins(:user_my_modules)
.where('user_my_modules.user_id IN (?)', user.id)
.where(archived: false)
.distinct
end
end
end end

View file

@ -33,7 +33,7 @@
</span> </span>
<% end %> <% end %>
<div id="zoom-level-buttons" class="btn-group pull-right" data-toggle="buttons"> <div id="zoom-level-buttons" class="btn-group <%= 'pull-right' if can_edit_canvas(@experiment) && can_create_experiment(@project) %>" 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 %> <%=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 %>
<span class="glyphicon glyphicon-th-large" aria-hidden="true" ></span> <span class="glyphicon glyphicon-th-large" aria-hidden="true" ></span>
<% end %> <% end %>