diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index df40eb378..b8165e56b 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -691,9 +691,22 @@ class ProjectsController < ApplicationController redirect_to settings_project_url(@project, :tab => 'modules') end + GITLABTYPE = "Repository::Gitlab" def archive if request.post? - unless @project.archive + if @project.archive + # 删除版本库信息 + begin + g = Gitlab.client + g.delete_project(@project.gpid) + rescue Exception => e + puts e + end + # 删除Trustie班额本库记录 + repoisitory = Repository.where(:project_id => @project.id, :type => GITLABTYPE).first + repoisitory.delete + @project.update_column(:gpid, nil) + else flash[:error] = l(:error_can_not_archive_project) end end diff --git a/app/views/projects/settings/_new_edit.html.erb b/app/views/projects/settings/_new_edit.html.erb index 3a2408504..a2ccbd967 100644 --- a/app/views/projects/settings/_new_edit.html.erb +++ b/app/views/projects/settings/_new_edit.html.erb @@ -41,7 +41,7 @@
<%= link_to(l(:button_delete_project), { :controller => 'projects', :action => 'archive', :id => @project, :status => params[:status], :type =>"project" }, - :data => {:confirm => l(:text_are_you_sure)}, :method => :post) unless @project.archived? %> + :data => {:confirm => l(:text_delete_project_are_you_sure)}, :method => :post) unless @project.archived? %> <%#=link_to "删除该课程", course_path(@course), :method => :delete, :confirm=>"确认要删除该课程吗?" %> (友情提示:删除该项目后如果您想恢复该项目,请联系系统管理员!)
diff --git a/config/locales/commons/zh.yml b/config/locales/commons/zh.yml index 985fd9bc3..ec65b24bb 100644 --- a/config/locales/commons/zh.yml +++ b/config/locales/commons/zh.yml @@ -189,6 +189,7 @@ zh: text_are_you_sure: 您确定要删除吗? #js 提示 text_history_are_you_sure: 本资源有多个版本,你确定要全部删除吗? + text_delete_project_are_you_sure: 本项目包含版本库,项目删除后,版本库将被彻底删除。您确定删除吗? text_are_you_sure_out: 你确定要退出该班级吗? text_are_you_sure_out_group: 你确定要退出该分班吗? text_are_you_sure_all: 您确定要删除所有文件吗