diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 2bdaddb25..304ab8e02 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -739,7 +739,7 @@ class ProjectsController < ApplicationController rescue Exception => e puts e end - # 删除Trustie班额本库记录 + # 删除Trustie版本库记录 repoisitory = Repository.where(:project_id => @project.id, :type => GITLABTYPE).first repoisitory.delete @project.update_column(:gpid, nil) @@ -799,6 +799,31 @@ class ProjectsController < ApplicationController @project = nil end + REP_TYPE = "Repository::Gitlab" + # Delete @project's repository + def destroy_repository + if is_project_manager?(User.current.id, @project.id) + @gitlab_repository = Repository.where(:project_id => @project, :type => REP_TYPE).first + @is_true = params[:is_true] + if @is_true + begin + g = Gitlab.client + @gitlab_repository.destroy + @gitlab_repository = nil + @project.update_attribute(:gpid, nil) + scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first + @repository = Repository.factory(scm) + @repository.is_default = @project.repository.nil? + g.delete_project(@project.gpid) + rescue Exception => e + puts e + end + end + else + return render_403 + end + end + def show_projects_score respond_to do |format| format.html { render :layout => "base_projects"} diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 3dff9c414..fb757665f 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -302,6 +302,16 @@ module ProjectsHelper type << option2 end + # 判断用户是否为项目管理员 + def is_project_manager?(user_id, project_id) + @result = false + mem = Member.where("user_id = ? and project_id = ?",user_id, project_id) + unless mem.blank? + @result = mem.first.roles.to_s.include?("Manager") ? true : false + end + return @result + end + # 用来判断用户是否是项目的管理员 # added by william def is_manager?(user_id,project_id) diff --git a/app/views/projects/_reposistory_destory_pop.html.erb b/app/views/projects/_reposistory_destory_pop.html.erb new file mode 100644 index 000000000..1f8dd06f2 --- /dev/null +++ b/app/views/projects/_reposistory_destory_pop.html.erb @@ -0,0 +1,22 @@ +
+
+

提示

+ +
+
+
+ +
+
\ No newline at end of file diff --git a/app/views/projects/destroy_repository.js.erb b/app/views/projects/destroy_repository.js.erb new file mode 100644 index 000000000..3bc1d727b --- /dev/null +++ b/app/views/projects/destroy_repository.js.erb @@ -0,0 +1,6 @@ +<% if @is_true %> +$("#pro_st_tbc_06").html('<%= escape_javascript( render :partial => 'projects/settings/new_repositories') %>'); +<% else %> +var htmlvalue = "<%= escape_javascript(render :partial => 'projects/reposistory_destory_pop') %>"; +pop_box_new(htmlvalue,460,316); +<% end %> diff --git a/app/views/projects/settings/_new_repositories.html.erb b/app/views/projects/settings/_new_repositories.html.erb index a531e904a..1fb4f7b7a 100644 --- a/app/views/projects/settings/_new_repositories.html.erb +++ b/app/views/projects/settings/_new_repositories.html.erb @@ -14,7 +14,7 @@ - <%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false, :label=>"", :no_label => true, :class => "w650 fl", :style => "height: 28px;", :id => "project_setting_repository" %> + <%= f.text_field :identifier, :disabled => @repository.nil? || @repository.identifier_frozen? ? true:false, :label=>"", :no_label => true, :class => "w650 fl", :style => "height: 28px;", :id => "project_setting_repository" %>
  • @@ -35,14 +35,22 @@ 版本库名 管理系统 - 库路径 + 库路径 +   <%= @gitlab_repository.identifier %> Git - <%=h @repos_url %> + <%=h @repos_url %> + + <% if is_project_manager?(User.current.id, @project.id) %> + <%= link_to "删除", destroy_repository_project_path(@project), :class => "c_blue", :remote => true %> + <% else %> + <%= "删除" %> + <% end %> + diff --git a/config/routes.rb b/config/routes.rb index 3848c4b46..db1ad27e3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -783,6 +783,7 @@ RedmineApp::Application.routes.draw do get 'file', :action => 'file', :as => 'file' get 'statistics', :action => 'statistics', :as => 'statistics' get 'repository_tree_changes', :action => 'repository_tree_changes', :as => 'repository_tree_changes' + get 'destroy_repository', :action => 'destroy_repository', :as => 'destroy_repository' get 'feedback', :action => 'feedback', :as => 'project_feedback' get 'watcherlist', :action=> 'watcherlist' diff --git a/public/stylesheets/css/common.css b/public/stylesheets/css/common.css index 455047d91..296a009f1 100644 --- a/public/stylesheets/css/common.css +++ b/public/stylesheets/css/common.css @@ -233,6 +233,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/ .w20{ width:20px;} .w40{width: 40px;} .w45{ width: 45px;} +.w46{ width: 46px;} .w48{width:48px;} .w50 {width:50px;} .w56 {width:56px;}