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
.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
%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)