[#446] alias api

This commit is contained in:
Alexander Machehin 2015-02-04 17:02:45 +05:00
parent d9fa42af52
commit b245c2a808
2 changed files with 11 additions and 7 deletions

View File

@ -67,14 +67,17 @@ class Api::V1::ProjectsController < Api::V1::BaseController
update_member_in_subject @project
end
def fork
def fork(is_alias = false)
owner = (Group.find params[:group_id] if params[:group_id].present?) || current_user
authorize! :write, owner if owner.class == Group
if forked = @project.fork(owner, new_name: params[:fork_name]) and forked.valid?
if forked = @project.fork(owner, new_name: params[:fork_name], is_alias: is_alias) and forked.valid?
render_json_response forked, 'Project has been forked successfully'
else
render_validation_error forked, 'Project has not been forked'
end
end
def alias
fork(true)
end
end

View File

@ -76,12 +76,13 @@ Rosa::Application.routes.draw do
resources :projects, only: [:index, :show, :update, :create, :destroy] do
collection { get :get_id }
member {
post :fork
get :refs_list
get :members
put :add_member
post :fork
post :alias
get :refs_list
get :members
put :add_member
delete :remove_member
put :update_member
put :update_member
}
resources :build_lists, only: :index
resources :issues, only: [:index, :create, :show, :update]