Merge pull request #72 from ZmagoD/zd_fix_exl_archive

fixed experiments archive bug
This commit is contained in:
Zmago Devetak 2016-08-18 13:16:51 +02:00 committed by GitHub
commit a680b09cc9
2 changed files with 9 additions and 6 deletions

View file

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

View file

@ -149,12 +149,18 @@ class Project < ActiveRecord::Base
if role.blank?
MyModule.none
elsif role == 'owner'
project_my_modules.where(archived: false)
project_my_modules
.joins(:experiment)
.where('experiments.archived=false')
.where('my_modules.archived=false')
else
project_my_modules
.joins(:user_my_modules)
.where('user_my_modules.user_id IN (?)', user.id)
.where(archived: false)
.joins(:experiment)
.where('experiments.archived=false AND user_my_modules.user_id IN (?)',
user.id)
.where('my_modules.archived=false')
.distinct
end
end