版本库删除功能

This commit is contained in:
huang 2017-03-08 18:32:08 +08:00
parent ca6058d120
commit 679a6274e6
3 changed files with 13 additions and 15 deletions

View File

@ -1135,18 +1135,21 @@ class ProjectsController < ApplicationController
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
unless @is_true.nil?
begin
g = Gitlab.client
g.delete_project(@project.gpid)
@gitlab_repository.destroy
@gitlab_repository = nil
scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
@repository = Repository.factory(scm)
@repository.is_default = @project.repository.nil?
@project.update_attribute(:gpid, nil)
d_project = g.delete_project(@project.gpid)
if d_project
@gitlab_repository.destroy
@project.update_attribute(:gpid, nil)
@gitlab_repository = nil
end
rescue Exception => e
puts e
if @gitlab_repository
@gitlab_repository.destroy
@project.update_attribute(:gpid, nil)
@gitlab_repository = nil
end
end
end
else

View File

@ -47,11 +47,6 @@
<input class="fl mt8 ml5" id="project_hidden_repo" name="project[hidden_repo]" type="checkbox" <%= @project.hidden_repo ? "checked" : ""%>>
</li>
<li class="clear">
<% if Member.where(:user_id => User.current.id, :project_id => @project.id).first.try(:roles).to_s.include?("Manager") %>
<%= link_to(l(:button_delete_project), project_path(@project, :type => "project"), :method => :delete, :class => 'sy_btn_grey mr5 fl ml15',
:data => {:confirm => l(:text_delete_project_are_you_sure)}) %>
<p class="fl c_grey">(友情提示:删除操作会彻底删除项目的所有信息,一旦删除不能恢复!)</p>
<% end %>
<a href="javascript:void(0)" class="sy_btn_blue mr15 fr" onclick="submit_edit_project(<%= @project.id %>);" >保存</a>
</li>
</ul>

View File

@ -14,7 +14,7 @@
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label class=" fl"><span class="c_red f12">*</span>&nbsp;版本库名称&nbsp;&nbsp;:&nbsp;</label>
<%= 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, :label=>"", :no_label => true, :class => "w650 fl", :style => "height: 28px;", :id => "project_setting_repository" %>
<span style="display: none" class="c_orange ml100" id="valid_repository_name">版本库名是无效的</span>
</li>
<li class="clear">