[#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

@ -77,6 +77,7 @@ Rosa::Application.routes.draw do
collection { get :get_id }
member {
post :fork
post :alias
get :refs_list
get :members
put :add_member