版本库添加删除功能
This commit is contained in:
parent
c74fe9278a
commit
67a9d04a64
|
@ -739,7 +739,7 @@ class ProjectsController < ApplicationController
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
puts e
|
puts e
|
||||||
end
|
end
|
||||||
# 删除Trustie班额本库记录
|
# 删除Trustie版本库记录
|
||||||
repoisitory = Repository.where(:project_id => @project.id, :type => GITLABTYPE).first
|
repoisitory = Repository.where(:project_id => @project.id, :type => GITLABTYPE).first
|
||||||
repoisitory.delete
|
repoisitory.delete
|
||||||
@project.update_column(:gpid, nil)
|
@project.update_column(:gpid, nil)
|
||||||
|
@ -799,6 +799,31 @@ class ProjectsController < ApplicationController
|
||||||
@project = nil
|
@project = nil
|
||||||
end
|
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
|
def show_projects_score
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :layout => "base_projects"}
|
format.html { render :layout => "base_projects"}
|
||||||
|
|
|
@ -302,6 +302,16 @@ module ProjectsHelper
|
||||||
type << option2
|
type << option2
|
||||||
end
|
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
|
# added by william
|
||||||
def is_manager?(user_id,project_id)
|
def is_manager?(user_id,project_id)
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<div style="width:460px;">
|
||||||
|
<div class="sy_popup_top">
|
||||||
|
<h3 class="fl">提示</h3>
|
||||||
|
<a href="javascript:void(0);" class="sy_icons_close fr" onclick="hideModal()"></a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="sy_popup_con" style="width:380px;">
|
||||||
|
<ul class="sy_popup_add" >
|
||||||
|
<li class="center mb5" style="line-height:20px">
|
||||||
|
删除操作会彻底删除版本库及源码,一旦删除不能恢复</br>
|
||||||
|
你确定删除吗?
|
||||||
|
</li>
|
||||||
|
<li class="mt10">
|
||||||
|
<label class="mr27"> </label>
|
||||||
|
<a href="javascript:void(0);" class="sy_btn_grey fl " onclick="hideModal()">取 消</a>
|
||||||
|
<!-- <a href="<%#= {:controller => 'repositories', :action => 'forked'} %>" class="sy_btn_blue fl ml20" onclick="hideModal();">确 定</a>-->
|
||||||
|
<%= link_to "确 定", destroy_repository_project_path(@project, :is_true => true), :remote => true, :class => "sy_btn_blue fl ml20", :onclick => "hideModal();" %>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -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 %>
|
|
@ -14,7 +14,7 @@
|
||||||
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
||||||
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
||||||
<label class=" fl"><span class="c_red f12">*</span> 版本库名称 : </label>
|
<label class=" fl"><span class="c_red f12">*</span> 版本库名称 : </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, :disabled => @repository.nil? || @repository.identifier_frozen? ? true:false, :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>
|
<span style="display: none" class="c_orange ml100" id="valid_repository_name">版本库名是无效的</span>
|
||||||
</li>
|
</li>
|
||||||
<li class="clear">
|
<li class="clear">
|
||||||
|
@ -35,14 +35,22 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w130 pl10 pr10 hidden fl">版本库名</th>
|
<th class="w130 pl10 pr10 hidden fl">版本库名</th>
|
||||||
<th class="w90 pr10 hidden fl">管理系统</th>
|
<th class="w90 pr10 hidden fl">管理系统</th>
|
||||||
<th class="w536 hidden fl">库路径</th>
|
<th class="w490 hidden fl">库路径</th>
|
||||||
|
<th class="w46 hidden fl"> </th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w130 pl10 pr10 hidden fl"><%= @gitlab_repository.identifier %></th>
|
<th class="w130 pl10 pr10 hidden fl"><%= @gitlab_repository.identifier %></th>
|
||||||
<th class="w90 pr10 hidden fl">Git</th>
|
<th class="w90 pr10 hidden fl">Git</th>
|
||||||
<th class="w536 hidden fl"><%=h @repos_url %></th>
|
<th class="w490 hidden fl"><%=h @repos_url %></th>
|
||||||
|
<th class="w46 hidden fl">
|
||||||
|
<% if is_project_manager?(User.current.id, @project.id) %>
|
||||||
|
<%= link_to "删除", destroy_repository_project_path(@project), :class => "c_blue", :remote => true %>
|
||||||
|
<% else %>
|
||||||
|
<%= "删除" %>
|
||||||
|
<% end %>
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -783,6 +783,7 @@ RedmineApp::Application.routes.draw do
|
||||||
get 'file', :action => 'file', :as => 'file'
|
get 'file', :action => 'file', :as => 'file'
|
||||||
get 'statistics', :action => 'statistics', :as => 'statistics'
|
get 'statistics', :action => 'statistics', :as => 'statistics'
|
||||||
get 'repository_tree_changes', :action => 'repository_tree_changes', :as => 'repository_tree_changes'
|
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 'feedback', :action => 'feedback', :as => 'project_feedback'
|
||||||
get 'watcherlist', :action=> 'watcherlist'
|
get 'watcherlist', :action=> 'watcherlist'
|
||||||
|
|
|
@ -233,6 +233,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
|
||||||
.w20{ width:20px;}
|
.w20{ width:20px;}
|
||||||
.w40{width: 40px;}
|
.w40{width: 40px;}
|
||||||
.w45{ width: 45px;}
|
.w45{ width: 45px;}
|
||||||
|
.w46{ width: 46px;}
|
||||||
.w48{width:48px;}
|
.w48{width:48px;}
|
||||||
.w50 {width:50px;}
|
.w50 {width:50px;}
|
||||||
.w56 {width:56px;}
|
.w56 {width:56px;}
|
||||||
|
|
Loading…
Reference in New Issue