Merge branch 'dev_newproject' of https://git.trustie.net/jacknudt/trustieforge into dev_newproject
This commit is contained in:
commit
dfcf93082a
|
@ -27,7 +27,7 @@ class ProjectsController < ApplicationController
|
||||||
menu_item :feedback, :only => :feedback
|
menu_item :feedback, :only => :feedback
|
||||||
menu_item :share, :only => :share
|
menu_item :share, :only => :share
|
||||||
|
|
||||||
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project]
|
before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches,:join_project, :forked_pop]
|
||||||
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
|
before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course]
|
||||||
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
|
before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches]
|
||||||
before_filter :require_admin, :only => [ :copy, :unarchive, :destroy, :calendar]
|
before_filter :require_admin, :only => [ :copy, :unarchive, :destroy, :calendar]
|
||||||
|
@ -760,6 +760,13 @@ class ProjectsController < ApplicationController
|
||||||
redirect_to admin_projects_url(:status => params[:status])
|
redirect_to admin_projects_url(:status => params[:status])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 资源库fork弹框
|
||||||
|
def forked_pop
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def close
|
def close
|
||||||
@project.close
|
@project.close
|
||||||
redirect_to project_url(@project)
|
redirect_to project_url(@project)
|
||||||
|
@ -946,5 +953,4 @@ class ProjectsController < ApplicationController
|
||||||
return projects
|
return projects
|
||||||
end
|
end
|
||||||
#gcmend
|
#gcmend
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,35 +87,38 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def forked
|
def forked
|
||||||
@project = Project.find(params[:id])
|
respond_to do |format|
|
||||||
@repository = Repository.where("project_id =? and type =?", @project.id, "Repository::Gitlab")
|
format.html{
|
||||||
# 如果当前用户已经fork过该项目,不会新fork项目,则跳至已fork的项
|
@project = Project.find(params[:id])
|
||||||
unless has_forked?(@project, User.current)
|
@repository = Repository.where("project_id =? and type =?", @project.id, "Repository::Gitlab")
|
||||||
project = project_from_current_project(@project.id, User.current.id)
|
# 如果当前用户已经fork过该项目,不会新fork项目,则跳至已fork的项
|
||||||
redirect_to project_path(project)
|
unless has_forked?(@project, User.current)
|
||||||
else
|
project = project_from_current_project(@project.id, User.current.id)
|
||||||
# 自己不能fork自己的项目
|
redirect_to project_path(project)
|
||||||
if User.current.id == @project.user_id
|
else
|
||||||
flash[:notice] = l(:project_gitlab_fork_own)
|
# 自己不能fork自己的项目
|
||||||
redirect_to repository_url(@repository)
|
if User.current.id == @project.user_id
|
||||||
else
|
flash[:notice] = l(:project_gitlab_fork_own)
|
||||||
g = Gitlab.client
|
redirect_to repository_url(@repository)
|
||||||
if User.current.gid.nil?
|
else
|
||||||
begin
|
g = Gitlab.client
|
||||||
g.sync_user(User.current)
|
if User.current.gid.nil?
|
||||||
ensure
|
begin
|
||||||
logger.error "Synv user failed ==>#{User.current.id}"
|
g.sync_user(User.current)
|
||||||
|
ensure
|
||||||
|
logger.error "Synv user failed ==>#{User.current.id}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
gproject = g.fork(@project.gpid, User.current.gid)
|
||||||
|
if gproject
|
||||||
|
copy_project(@project, gproject)
|
||||||
|
forked_count = @project.forked_count.to_i + 1
|
||||||
|
@project.update_attributes(:forked_count => forked_count)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
gproject = g.fork(@project.gpid, User.current.gid)
|
}
|
||||||
if gproject
|
|
||||||
copy_project(@project, gproject)
|
|
||||||
forked_count = @project.forked_count.to_i + 1
|
|
||||||
@project.update_attributes(:forked_count => forked_count)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# 一键ZIP下载
|
# 一键ZIP下载
|
||||||
|
|
|
@ -18,16 +18,25 @@
|
||||||
<% else %>
|
<% else %>
|
||||||
<!--项目创建者不能退出项目-->
|
<!--项目创建者不能退出项目-->
|
||||||
<% if User.current.id != @project.user_id %>
|
<% if User.current.id != @project.user_id %>
|
||||||
<%= "已加入" %>
|
<li class="mr5 fl">
|
||||||
<%= link_to "#{Member.where(:project_id => @project.id).count}", project_member_path(@project), :class => 'pro_new_topbtn fl', :title => "项目成员" %>
|
<a href="javascript:void(0);" class="pro_new_topbtn_left fl "> 已加入</a>
|
||||||
|
<a href="<%= project_member_path(@project) %>" class=" pro_new_topbtn fl"><%= Member.where(:project_id => @project.id).count %></a>
|
||||||
|
</li>
|
||||||
|
<%#= link_to "#{Member.where(:project_id => @project.id).count}", project_member_path(@project), :class => 'pro_new_topbtn fl', :title => "项目成员" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<!--项目fork-->
|
<!--项目fork-->
|
||||||
<% if @project.gpid && User.current.id != @project.user_id %>
|
<% if @project.gpid && User.current.id != @project.user_id %>
|
||||||
<div class="fr mt5"><%= link_to "<span class='vl_fork'></span>".html_safe+"Fork", {:controller => 'repositories', :action => 'forked'}, :class=>"vl_btn", :target => "_blank", :confirm=>"平台将为您创建一个新的同名项目和版本库,请问是否继续?" %>
|
<!-- <div class="fr mt5"><%#= link_to "<span class='vl_fork'></span>".html_safe+"Fork", {:controller => 'repositories', :action => 'forked'},
|
||||||
<span href="javascript:void(0);" class="vl_btn_2 fb"><%= link_to @project.forked_count.to_i, member_forked_project_path(@project) %></span>
|
:class=>"vl_btn", :target => "_blank", :confirm=>"平台将为您创建一个新的同名项目和版本库,请问是否继续?" %>
|
||||||
</div>
|
<span href="javascript:void(0);" class="vl_btn_2 fb"><%#= link_to @project.forked_count.to_i, member_forked_project_path(@project) %></span>
|
||||||
|
</div>-->
|
||||||
|
<li class="mr5 fl">
|
||||||
|
<!-- <a href="<%#= {:controller => 'repositories', :action => 'forked'} %>" class="pro_new_topbtn_left fl" target="_blank">Fork</a>-->
|
||||||
|
<%= link_to "Fork", {:controller => 'projects', :action => 'forked_pop'},
|
||||||
|
:class=>"pro_new_topbtn_left fl", :remote => true %>
|
||||||
|
<a href="<%= member_forked_project_path(@project) %>" class=" pro_new_topbtn fl"><%= @project.forked_count.to_i %></a>
|
||||||
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
var htmlvalue = "<%= escape_javascript(render :partial => 'repositories/forked_popbox') %>";
|
||||||
|
pop_box_new(htmlvalue,820,316);
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
<div id="muban_popup_box" style="width:820px;">
|
||||||
|
<div class="muban_popup_top">
|
||||||
|
<h3 class="fl">新建里程碑</h3>
|
||||||
|
<a href="javascript:void(0);" class="muban_icons_close fr" onclick="hideModal()"></a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -795,6 +795,7 @@ RedmineApp::Application.routes.draw do
|
||||||
post 'unarchive'
|
post 'unarchive'
|
||||||
post 'close'
|
post 'close'
|
||||||
post 'reopen'
|
post 'reopen'
|
||||||
|
get 'forked_pop'
|
||||||
get 'search_public_orgs_not_in_project'
|
get 'search_public_orgs_not_in_project'
|
||||||
match 'copy', :via => [:get, :post]
|
match 'copy', :via => [:get, :post]
|
||||||
match 'set_public_or_private', :via => [:post]
|
match 'set_public_or_private', :via => [:post]
|
||||||
|
@ -809,7 +810,6 @@ RedmineApp::Application.routes.draw do
|
||||||
match '/file', :to => 'projects#file', :as => 'file', :via => :get
|
match '/file', :to => 'projects#file', :as => 'file', :via => :get
|
||||||
match '/statistics', :to => 'projects#statistics', :as => 'statistics', :via => :get
|
match '/statistics', :to => 'projects#statistics', :as => 'statistics', :via => :get
|
||||||
match '/watcherlist', :to=>'projects#watcherlist', :as => 'watcherlist', :via => :get #add by huang
|
match '/watcherlist', :to=>'projects#watcherlist', :as => 'watcherlist', :via => :get #add by huang
|
||||||
|
|
||||||
resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
|
resources :memberships, :shallow => true, :controller => 'members', :only => [:index, :show, :new, :create, :update, :destroy] do
|
||||||
collection do
|
collection do
|
||||||
get 'autocomplete'
|
get 'autocomplete'
|
||||||
|
|
Loading…
Reference in New Issue