diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 059e55e0a..107f2ff88 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -27,7 +27,7 @@ class ProjectsController < ApplicationController menu_item :feedback, :only => :feedback 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_global, :only => [:new, :create,:view_homework_attaches] before_filter :require_admin, :only => [ :copy, :unarchive, :destroy, :calendar] @@ -760,6 +760,13 @@ class ProjectsController < ApplicationController redirect_to admin_projects_url(:status => params[:status]) end + # 资源库fork弹框 + def forked_pop + respond_to do |format| + format.js + end + end + def close @project.close redirect_to project_url(@project) @@ -946,5 +953,4 @@ class ProjectsController < ApplicationController return projects end #gcmend - end diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 47cc90ebc..146f49219 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -87,35 +87,38 @@ class RepositoriesController < ApplicationController end def forked - @project = Project.find(params[:id]) - @repository = Repository.where("project_id =? and type =?", @project.id, "Repository::Gitlab") - # 如果当前用户已经fork过该项目,不会新fork项目,则跳至已fork的项 - unless has_forked?(@project, User.current) - project = project_from_current_project(@project.id, User.current.id) - redirect_to project_path(project) - else - # 自己不能fork自己的项目 - if User.current.id == @project.user_id - flash[:notice] = l(:project_gitlab_fork_own) - redirect_to repository_url(@repository) - else - g = Gitlab.client - if User.current.gid.nil? - begin - g.sync_user(User.current) - ensure - logger.error "Synv user failed ==>#{User.current.id}" + respond_to do |format| + format.html{ + @project = Project.find(params[:id]) + @repository = Repository.where("project_id =? and type =?", @project.id, "Repository::Gitlab") + # 如果当前用户已经fork过该项目,不会新fork项目,则跳至已fork的项 + unless has_forked?(@project, User.current) + project = project_from_current_project(@project.id, User.current.id) + redirect_to project_path(project) + else + # 自己不能fork自己的项目 + if User.current.id == @project.user_id + flash[:notice] = l(:project_gitlab_fork_own) + redirect_to repository_url(@repository) + else + g = Gitlab.client + if User.current.gid.nil? + begin + 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 - 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 # 一键ZIP下载 diff --git a/app/views/projects/_applied_status.html.erb b/app/views/projects/_applied_status.html.erb index 3193e8e95..8c51cf1f6 100644 --- a/app/views/projects/_applied_status.html.erb +++ b/app/views/projects/_applied_status.html.erb @@ -18,16 +18,25 @@ <% else %> <% if User.current.id != @project.user_id %> - <%= "已加入" %> - <%= link_to "#{Member.where(:project_id => @project.id).count}", project_member_path(@project), :class => 'pro_new_topbtn fl', :title => "项目成员" %> +