Commit de12eba2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Dont show fork button in personal projects. Point to fork if already forked project

parent 7b6f2fb1
...@@ -69,7 +69,6 @@ class Ability ...@@ -69,7 +69,6 @@ class Ability
:download_code, :download_code,
:write_snippet, :write_snippet,
:fork_project :fork_project
] ]
end end
......
...@@ -326,4 +326,18 @@ class User < ActiveRecord::Base ...@@ -326,4 +326,18 @@ class User < ActiveRecord::Base
def tm_of(project) def tm_of(project)
project.team_member_by_id(self.id) project.team_member_by_id(self.id)
end end
def already_forked? project
!!fork_of(project)
end
def fork_of project
links = ForkedProjectLink.where(forked_from_project_id: project, forked_to_project_id: personal_projects)
if links.any?
links.first.forked_to_project
else
nil
end
end
end end
...@@ -5,7 +5,11 @@ ...@@ -5,7 +5,11 @@
.span3.pull-right .span3.pull-right
.pull-right .pull-right
- unless @project.empty_repo? - unless @project.empty_repo?
- if can? current_user, :fork_project, @project - if can?(current_user, :fork_project, @project) && @project.namespace != current_user.namespace
- if current_user.already_forked?(@project)
= link_to project_path(current_user.fork_of(@project)), class: 'btn grouped success' do
Forked
- else
= link_to fork_project_path(@project), title: "Fork", class: "btn grouped", method: "POST" do = link_to fork_project_path(@project), title: "Fork", class: "btn grouped", method: "POST" do
%i.icon-copy %i.icon-copy
Fork Fork
......
...@@ -40,3 +40,7 @@ ...@@ -40,3 +40,7 @@
%p Repo Size: #{@project.repository.size} MB %p Repo Size: #{@project.repository.size} MB
%p Created at: #{@project.created_at.stamp('Aug 22, 2013')} %p Created at: #{@project.created_at.stamp('Aug 22, 2013')}
%p Owner: #{link_to @project.owner_name, @project.owner} %p Owner: #{link_to @project.owner_name, @project.owner}
- if @project.forked_from_project
%p
Forked from:
= link_to @project.forked_from_project.name_with_namespace, project_path(@project.forked_from_project)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment