1 class ProjectsController < ApplicationController
11 %w(Data_collections Jobs_and_pipelines Pipeline_templates Subprojects Other_objects Permissions Advanced)
15 params[:item_uuids] = [params[:item_uuid]]
17 render template: 'projects/remove_items'
23 params[:item_uuids].collect { |uuid| ArvadosBase.find uuid }.each do |item|
24 if (item.class == Link and
25 item.link_class == 'name' and
26 item.tail_uuid == @object.uuid)
27 # Given uuid is a name link, linking an object to this
28 # project. First follow the link to find the item we're removing,
29 # then delete the link.
31 item = ArvadosBase.find item.head_uuid
33 # Given uuid is an object. Delete all names.
34 links += Link.where(tail_uuid: @object.uuid,
39 @removed_uuids << link.uuid
42 if item.owner_uuid == @object.uuid
43 # Object is owned by this project. Remove it from the project by
44 # changing owner to the current user.
45 item.update_attributes owner_uuid: current_user.uuid
46 @removed_uuids << item.uuid
52 while (objects = Link.filter([['owner_uuid','=',@object.uuid],
53 ['tail_uuid','=',@object.uuid]])).any?
54 objects.each do |object|
58 while (objects = @object.contents(include_linked: false)).any?
59 objects.each do |object|
60 object.update_attributes! owner_uuid: current_user.uuid
63 if ArvadosBase::resource_class_for_uuid(@object.owner_uuid) == Group
64 params[:return_to] ||= group_path(@object.owner_uuid)
66 params[:return_to] ||= projects_path
71 def find_objects_for_index
72 @objects = all_projects
78 return render_not_found("object not found")
80 @objects = @object.contents(limit: 50,
82 filters: params[:filters],
83 offset: params[:offset] || 0)
84 @share_links = Link.filter([['head_uuid', '=', @object.uuid],
85 ['link_class', '=', 'permission']])
86 @logs = Log.limit(10).filter([['object_uuid', '=', @object.uuid]])
88 @objects_and_names = get_objects_and_names @objects
94 content: render_to_string(partial: 'show_contents_rows.html',
97 objects_and_names: @objects_and_names,
100 next_page_href: (next_page_offset and
101 url_for(offset: next_page_offset, partial: true))
111 @new_resource_attrs = (params['project'] || {}).merge(group_class: 'project')
112 @new_resource_attrs[:name] ||= 'New project'
117 @updates = params['project']
121 helper_method :get_objects_and_names
122 def get_objects_and_names(objects)
123 objects_and_names = []
124 objects.each do |object|
125 if !(name_links = objects.links_for(object, 'name')).empty?
126 name_links.each do |name_link|
127 objects_and_names << [object, name_link]
129 elsif object.respond_to? :name
130 objects_and_names << [object, object]
132 objects_and_names << [object,
133 Link.new(owner_uuid: @object.uuid,
134 tail_uuid: @object.uuid,
135 head_uuid: object.uuid,