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
:download_code,
:write_snippet,
:fork_project
]
end
......
......@@ -326,4 +326,18 @@ class User < ActiveRecord::Base
def tm_of(project)
project.team_member_by_id(self.id)
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
......@@ -5,10 +5,14 @@
.span3.pull-right
.pull-right
- unless @project.empty_repo?
- if can? current_user, :fork_project, @project
= link_to fork_project_path(@project), title: "Fork", class: "btn grouped", method: "POST" do
%i.icon-copy
Fork
- 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
%i.icon-copy
Fork
- if can? current_user, :download_code, @project
= link_to archive_project_repository_path(@project), class: "btn grouped" do
%i.icon-download-alt
......
......@@ -40,3 +40,7 @@
%p Repo Size: #{@project.repository.size} MB
%p Created at: #{@project.created_at.stamp('Aug 22, 2013')}
%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