Skip to content

Commit

Permalink
[api] retire webui/relationships controller
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Oct 18, 2013
1 parent 2c2f6f0 commit afb060e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 64 deletions.
45 changes: 0 additions & 45 deletions src/api/app/controllers/webui/relationships_controller.rb

This file was deleted.

8 changes: 0 additions & 8 deletions src/api/config/routes.rb
Expand Up @@ -337,14 +337,6 @@
get 'infos'
get 'status'
end
collection do
get 'remotes'
end
resources :relationships, :only => [:create] do
collection do
delete :for_user, action: :remove_user
end
end
resources :flags, :only => [:index]
resources :packages, :only => [], constraints: { :id => %r{[^\/]*} } do
resources :relationships, :only => [:create] do
Expand Down
18 changes: 9 additions & 9 deletions src/api/webui/app/controllers/webui/project_controller.rb
Expand Up @@ -796,19 +796,19 @@ def move_path_down
redirect_to :action => :repositories, :project => @project
end

def change_role_options(params)
ret = Hash.new
ret[:role] = params[:role] if params.has_key? :role
if params.has_key? :userid
return ret.merge( { user: params[:userid] })
def load_obj
if login = params[:userid]
return User.get_by_login(login)
elsif title = params[:groupid]
return ::Group.get_by_title(title)
else
return ret.merge( { group: params[:groupid] })
raise MissingParameterError, "Neither user nor group given"
end
end

def save_person
begin
ApiDetails.create(:project_relationships, @project.name, change_role_options(params))
@project.api_project.add_role(load_obj, Role.find_by_title!(params[:role]))
@project.free_cache
rescue ApiDetails::TransportError, ApiDetails::NotFoundError, User::NotFound => e
flash[:error] = e.to_s
Expand All @@ -826,7 +826,7 @@ def save_person

def save_group
begin
ApiDetails.create :project_relationships, @project.name, change_role_options(params)
@project.api_project.add_role(load_obj, Role.find_by_title!(params[:role]))
@project.free_cache
rescue ApiDetails::TransportError, ApiDetails::NotFoundError, ::Group::NotFound => e
flash[:error] = e.to_s
Expand All @@ -844,7 +844,7 @@ def save_group

def remove_role
begin
ApiDetails.destroy :for_user_project_relationships, @project.name, change_role_options(params)
@project.api_project.remove_role(load_obj, Role.find_by_title(params[:role]))
@project.free_cache
rescue ApiDetails::TransportError, ApiDetails::NotFoundError, User::NotFound, ::Group::NotFound => e
flash[:error] = e.summary
Expand Down
2 changes: 0 additions & 2 deletions src/api/webui/app/models/webui/api_details.rb
Expand Up @@ -67,8 +67,6 @@ def self.http_do(verb, route_name, *args)
when :projects_remotes then "projects/remotes"
when :infos_project then "projects/#{ids.first}/infos"
when :status_project then "projects/#{ids.first}/status"
when :project_relationships then "projects/#{ids.first}/relationships"
when :for_user_project_relationships then "projects/#{ids.first}/relationships/for_user"

when :package_rdiff then "projects/#{ids.first}/packages/#{ids.last}/rdiff"

Expand Down
4 changes: 4 additions & 0 deletions src/api/webui/app/models/webui_project.rb
Expand Up @@ -44,6 +44,10 @@ def to_s
to_hash["name"]
end

def api_project
Project.find_by_name(to_s)
end

def set_remoteurl(url)
logger.debug "set remoteurl"

Expand Down

0 comments on commit afb060e

Please sign in to comment.