Skip to content

Commit

Permalink
Add assets to the appropriate folders ELIXIR-Belgium#58
Browse files Browse the repository at this point in the history
  • Loading branch information
vdkkia committed Jul 28, 2022
1 parent 6b3e011 commit 1e0d17e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions app/models/project_folder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def authorized_assets

#assets that are not associated to any assay
def authorized_hanging_assets
assets.select{ |a| a.respond_to?(:assays) && a.assays.empty? && a.can_view? }
assets.select { |a| a.class.name != 'Sample' && a.can_view? }
end

#what is displayed in the tree
Expand All @@ -39,8 +39,13 @@ def count
authorized_hanging_assets.count
end

def self.new_items_folder project
ProjectFolder.where(:project_id=>project.id,:incoming=>true).first
def self.new_items_folder(project, asset=nil)
if asset.present?
folder_name = I18n.t(asset.class.name.underscore.downcase).pluralize
ProjectFolder.where(:project_id=>project.id, :title=>folder_name).first
else
ProjectFolder.where(:project_id=>project.id,:incoming=>true).first
end
end

#constucts the default project folders for a given project from a yaml file, by default using Rails.root/config/default_data/default_project_folders.yml
Expand Down
2 changes: 1 addition & 1 deletion lib/seek/acts_as_asset/folders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module Folders
module InstanceMethods
def add_new_to_folder
projects.each do |project|
pf = ProjectFolder.new_items_folder project
pf = ProjectFolder.new_items_folder(project, self)
pf.add_assets self unless pf.nil?
end
end
Expand Down

0 comments on commit 1e0d17e

Please sign in to comment.