1 class ProjectsController < ApplicationController
11 %w(Contents 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 offset: params[:offset] || 0)
83 @share_links = Link.filter([['head_uuid', '=', @object.uuid],
84 ['link_class', '=', 'permission']])
85 @logs = Log.limit(10).filter([['object_uuid', '=', @object.uuid]])
87 @objects_and_names = []
88 @objects.each do |object|
89 if !(name_links = @objects.links_for(object, 'name')).empty?
90 name_links.each do |name_link|
91 @objects_and_names << [object, name_link]
93 elsif object.respond_to? :name
94 @objects_and_names << [object, object]
96 @objects_and_names << [object,
97 Link.new(owner_uuid: @object.uuid,
98 tail_uuid: @object.uuid,
99 head_uuid: object.uuid,
108 content: render_to_string(partial: 'show_contents_rows.html',
111 objects_and_names: @objects_and_names,
114 next_page_href: (next_page_offset and
115 url_for(offset: next_page_offset, partial: true))
125 @new_resource_attrs = (params['project'] || {}).merge(group_class: 'project')
126 @new_resource_attrs[:name] ||= 'New project'
131 @updates = params['project']