Merge branch 'gitlab_guange' into szzh

This commit is contained in:
huang 2015-11-02 17:51:14 +08:00
commit eaa2ee7c19
13 changed files with 200 additions and 78 deletions

View File

@ -215,11 +215,11 @@ update
end
end
unless @repository.gitlab?
# redirect_to to_gitlab_project_repository_path(@project, @repository)
render :to_gitlab
return
end
# unless @repository.gitlab?
# # redirect_to to_gitlab_project_repository_path(@project, @repository)
# render :to_gitlab
# return
# end
#if( !User.current.member_of?(@project) || @project.hidden_repo)
@repository.fetch_changesets if Setting.autofetch_changesets? && @path.empty?
@ -252,11 +252,10 @@ update
project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT
ip = RepositoriesHelper::REPO_IP_ADDRESS
gitlab_address = Redmine::Configuration['gitlab_address']
if @repository.type.to_s=="Repository::Gitlab"
if @repository.type.to_s == "Repository::Gitlab"
@repos_url = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+@repository.identifier+"."+"git"
else
@repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s+
@repository.url.slice(project_path_cut, @repository.url.length).to_s
@repos_url = "http://"+@repository.login.to_s+"_"+@repository.identifier.to_s+"@"+ip.to_s + @repository.url.slice(project_path_cut, @repository.url.length).to_s
end
if @course_tag == 1
render :action => 'show', :layout => 'base_courses'

View File

@ -609,6 +609,12 @@ module ApplicationHelper
return @result
end
# 判断版本库是否初始为gitlab
def rep_is_gitlab?(project)
rep = Repository.where("project_id =? and type =?", project, "Repository::Gitlab")
return rep.blank? ? true :false
end
# 判断当前用户是否为项目管理员
def is_project_manager?(user_id, project_id)
@result = false

View File

@ -117,6 +117,22 @@ module ProjectsHelper
end
end
# 获取新增gitlab版本库
def rep_gitlab(project)
rep = Repository.where("project_id =? and type =?", project, "Repository::Gitlab")
end
# 获取新项目的版本库地址
def rep_gitlab_url(project)
gitlab_address = Redmine::Configuration['gitlab_address']
url = gitlab_address.to_s+"/"+project.owner.to_s+"/"+project.identifier+"."+"git"
end
# # 获取Forge历史版本库
def rep_forge(project)
rep = Repository.where("project_id =? and type =?", project, "Repository::Git")
end
# Added by young
def course_settings_tabs
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural, :course=>'1'},

View File

@ -41,8 +41,15 @@
<%# --版本库被设置成私有、module中设置不显示、没有创建版本库 三种情况不显示-- %>
<% if visible_repository?(@project) %>
<div class="subNav">
<%= link_to l(:project_module_repository), {:controller => 'repositories', :action => 'show', :id => @project.id, to: 'gitlab'}, :class => "f14 c_blue02" %>
<% if rep_is_gitlab?(@project) %>
<%= link_to l(:project_module_repository), {:controller => 'projects', :action => 'settings', :id => @project.id, :tab=>'repositories'}, :class => "f14 c_blue02" %>
<% else %>
<%= link_to l(:project_module_repository), {:controller => 'repositories', :action => 'show', :id => @project.id }, :class => "f14 c_blue02" %>
<% end %>
<a class="subnav_num">(<%= @project.repositories.count %>)</a>
<% if (User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project)) && rep_is_gitlab?(@project) %>
<%= link_to "+"+l(:project_module_create_repository), url_for(:controller => 'projects', :action => 'settings', :id => @project.id, :tab=>'repositories') , :class => "subnav_green" %>
<% end %>
</div>
<% end %>
<!-- more -->

View File

@ -7,87 +7,80 @@
<%= str = error_messages_for 'repository' %>
<% project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT %>
<% ip = RepositoriesHelper::REPO_IP_ADDRESS %><!--Added by tanxianbo For formatting project's path-->
<%# 新建版本库 %>
<% if @project.repositories.count == 0 || rep_is_gitlab?(@project) %>
<div style="padding-bottom: 40px">
<a href="javascript:viod(0)" class="pic_add fl mr5" onclick="pro_st_show_ku();"></a>
<a href="javascript:viod(0)" class="c_blue fl" onclick="pro_st_show_ku();">
<% course_tag = @project.project_type %>
<% if User.current.allowed_to?(:manage_repository, @project) %>
<!--newrepo_project_repository_path(@project, :course => course_tag) -->
<%= link_to l(:label_repository_new_repos),"#" , :onclick=>"pro_st_show_ku();", :class => 'c_blue fl' %></p>
<% end %>
</a>
<div class="cl"></div>
<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %>
<div id="pro_st_edit_ku" class="pro_st_edit_ku">
<ul>
<li style="display: none">
<label class="label02"><%=l(:label_scm)%></label>
<%= select_tag('repository_scm',
options_for_select(["Git"],@repository.class.name.demodulize),
:data => {:remote => true, :method => 'get'}) %>
<% if @repository && ! @repository.class.scm_available %>
<span class="c_grey"><%= l(:text_scm_command_not_available) %></span>
<% end %>
</li>
<li >
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label class="label02"><span class="c_red">*</span><%=l(:label_repository_name)%></label>
<%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %>
<% unless @repository.identifier_frozen? %>
<span class="c_grey"><%=l(:text_length_between,:min=>1,:max=>254)<<l(:text_project_identifier_info) %></span>
<% end %>
</li>
<div class="cl"></div>
</ul>
<a href="#" onclick="$('#repository-form').submit();" class="blue_btn fl ml38 "><%=l(:lable_project_rep_create) %></a>
<a href="<%= settings_project_path(@project, :tab => 'repositories')%>" class="grey_btn fl ml38 "><%=l(:button_cancel)%></a>
</div><!--pro_st_edit_issues end-->
<% end %>
</div>
<% end %>
<% if @project.repositories.any? %>
<%= render :partial => 'projects/settings/rep_gitlab', :locals => {:project => @project, :ip => "ip", :project_path_cut => "project_path_cut" } %>
<%#= render :partial => 'projects/settings/rep_forge', :locals => {:project => @project, :ip => "ip", :project_path_cut => "project_path_cut" } %>
<div class="rep_history_title">历史版本库</div>
<table class="pro_table">
<tbody>
<tr class="pro_table_tit">
<td class=" w150"><%= l(:field_identifier) %></td>
<td class="w150"> <%= l(:field_repository_is_default) %></td>
<td class="w150"><%= l(:label_scm) %> </td>
<td class="w150" ><%= l(:label_repository_path) %> </td>
<td class="w150"> </td>
<td class="w150"> </td>
</tr>
<% @project.repositories.sort.each do |repository| %>
<tr class="<%= cycle 'pro_table_on', '' %>">
<td><a href="javascript:viod(0)" title="<%= repository.identifier %>">
<%= link_to truncate(repository.identifier), ({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => repository.identifier_param} if repository.identifier.present?) %></a></td>
<td> <%= checked_image repository.is_default? %></td>
<td><%=h repository.scm_name %></td>
<% rep_forge(@project).sort.each do |repository| %>
<tr class="<%= cycle 'pro_table_on_forge', '' %>">
<td class="w150"><span class="rep_history_grey" title="<%= repository.identifier %>">
<%= repository.identifier %></span></td>
<td class="w150"><span class="rep_history_grey"><%=h repository.scm_name %></span></td>
<%if repository.scm_name=="Git"%>
<td style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="http://<%= repository.login.to_s %>_<%= repository.identifier.to_s%>@<%= ip %>
<%=h repository.url.slice(project_path_cut, repository.url.length) %>"> <%=truncate( 'http://' << repository.login.to_s << '_'<< repository.identifier.to_s << '@'<< ip.to_s << h( repository.url.slice(project_path_cut, repository.url.length)),:length=>20)%></td><!--Modified by tanxianbo-->
<td class="w362" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="http://<%= repository.login.to_s %>_<%= repository.identifier.to_s%>@<%= ip %>
<%=h repository.url.slice(project_path_cut, repository.url.length) %>">
<span class="rep_history_grey">
<%=truncate( 'http://' << repository.login.to_s << '_'<< repository.identifier.to_s << '@'<< ip.to_s << h( repository.url.slice(project_path_cut, repository.url.length)),:length=>60) %>
</span>
</td><!--Modified by tanxianbo-->
<%else %>
<td style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" ><%=h truncate(repository.url,:length=>10) %></td>
<td class="w360" style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" ><%=h truncate(repository.url,:length=>10) %></td>
<% end %>
<td><a href="javascript:viod(0)" class="c_blue" >
<% if repository.scm_name=="Git"%>
<%if User.current.allowed_to?(:manage_repository, @project) %>
<%= link_to(l(:label_user_plural), committers_repository_path(repository)) %>
<% end %>
<% end %>
</a></td>
<td>
<% if repository.login.to_s==User.current.login.to_s %>
<%= delete_new_link repository_path(repository) %>
<% end %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<p class="nodata"><%= l(:label_repository_no_data) %></p>
<p class="nodata">温馨提示:<%= l(:label_repository_no_data) %></p>
<% end %>
<%# 新建版本库 %>
<% if @project.repositories.count == 0 %>
<a href="javascript:viod(0)" class="pic_add fl mr5" onclick="pro_st_show_ku();"></a>
<a href="javascript:viod(0)" class="c_blue fl" onclick="pro_st_show_ku();">
<% course_tag = @project.project_type %>
<% if User.current.allowed_to?(:manage_repository, @project) %>
<!--newrepo_project_repository_path(@project, :course => course_tag) -->
<%= link_to l(:label_repository_new_repos),"#" , :onclick=>"pro_st_show_ku();", :class => 'c_blue fl' %></p>
<% end %>
</a>
<div class="cl"></div>
<%= labelled_form_for :repository, @repository, :url =>project_repositories_path(@project),:html => {:id => 'repository-form',:method=>"post",:autocomplete=>'off'} do |f| %>
<div id="pro_st_edit_ku" class="pro_st_edit_ku">
<ul>
<li >
<label class="label02"><%=l(:label_scm)%></label>
<%= select_tag('repository_scm',
options_for_select(["Git"],@repository.class.name.demodulize),
:data => {:remote => true, :method => 'get'})%>
<% if @repository && ! @repository.class.scm_available %>
<span class="c_grey"><%= l(:text_scm_command_not_available) %></span>
<% end %>
</li>
<li >
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
<label class="label02"><span class="c_red">*</span><%=l(:label_repository_name)%></label>
<%= f.text_field :identifier, :disabled =>@repository.nil? || @repository.identifier_frozen? ? true:false,:label=>"", :no_label => true %>
<% unless @repository.identifier_frozen? %>
<span class="c_grey"><%=l(:text_length_between,:min=>1,:max=>254)<<l(:text_project_identifier_info) %></span>
<% end %>
</li>
<div class="cl"></div>
</ul>
<a href="#" onclick="$('#repository-form').submit();" class="blue_btn fl ml110"><%=l(:button_save)%></a>
<a href="<%= settings_project_path(@project, :tab => 'repositories')%>" class="grey_btn fl ml10"><%=l(:button_cancel)%></a>
</div><!--pro_st_edit_issues end-->
<% end %>
<% end %>

View File

@ -0,0 +1,38 @@
<table class="pro_table">
<tbody>
<tr class="pro_table_tit">历史版本</tr>
<tr class="pro_table_tit">
<td class=" w150"><%= l(:field_identifier) %></td>
<td class="w150"> <%= l(:field_repository_is_default) %></td>
<td class="w150"><%= l(:label_scm) %> </td>
<td class="w150" ><%= l(:label_repository_path) %> </td>
<td class="w150"> </td>
<td class="w150"> </td>
</tr>
<% rep_forge(project).sort.each do |repository| %>
<tr class="<%= cycle 'pro_table_on', '' %>">
<td><a href="javascript:viod(0)" title="<%= repository.identifier %>">
<%= link_to truncate(repository.identifier), ({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => repository.identifier_param} if repository.identifier.present?) %></a></td>
<td> <%= checked_image repository.is_default? %></td>
<td><%=h repository.scm_name %></td>
<%if repository.scm_name=="Git"%>
<td style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="http://<%= repository.login.to_s %>_<%= repository.identifier.to_s%>@<%= ip %>
<%=h repository.url.slice(project_path_cut, repository.url.length) %>"> <%=truncate( 'http://' << repository.login.to_s << '_'<< repository.identifier.to_s << '@'<< ip.to_s << h( repository.url.slice(project_path_cut, repository.url.length)),:length=>20)%></td><!--Modified by tanxianbo-->
<%else %>
<td style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" ><%=h truncate(repository.url,:length=>10) %></td>
<% end %>
<td><a href="javascript:viod(0)" class="c_blue" >
<% if repository.scm_name=="Git"%>
<%if User.current.allowed_to?(:manage_repository, @project) %>
<%= link_to(l(:label_user_plural), committers_repository_path(repository)) %>
<% end %>
<% end %>
</a></td>
<td>
<% if repository.login.to_s==User.current.login.to_s %>
<%= delete_new_link repository_path(repository) %>
<% end %></td>
</tr>
<% end %>
</tbody>
</table>

View File

@ -0,0 +1,26 @@
<% rep_gitlab(project).sort.each do |repository| %>
<table class="pro_table">
<tbody>
<tr class="pro_table_tit">
<td class=" w150"><%= l(:field_identifier) %></td>
<td class="w150"><%= l(:label_scm) %> </td>
<td class="w362" ><%= l(:label_repository_path) %> </td>
</tr>
<tr class="<%= cycle 'pro_table_on', '' %>">
<td><a href="javascript:viod(0)" title="<%= repository.identifier %>">
<%= link_to truncate(repository.identifier), ({:controller => 'repositories', :action => 'show', :id => @project, :repository_id => repository.identifier_param} if repository.identifier.present?) %></a>
</td>
<td><%=h repository.scm_name %></td>
<%if repository.scm_name=="Gitlab"%>
<td style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="<%= rep_gitlab_url(project) %>">
<%=truncate(rep_gitlab_url(project), :length => 360) %>
</td>
<%else %>
<td style="white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" ><%=h truncate(repository.url,:length=>10) %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>

View File

@ -200,7 +200,7 @@ zh:
label_subject_empty: 主题不能为空
label_no_data: 没有任何数据可供显示
label_repository_no_data: 您还没有创建版本库,每个项目只允许创建一个版本库!
label_repository_no_data: 每个项目只能创建一个版本库!
# 项目、课程、用户公用
label_settings: 配置
label_information_plural: 信息

View File

@ -88,6 +88,8 @@ zh:
project_module_files: 资源库
project_module_repository: 版本库
project_module_create_repository: 创建版本库
project_gitlab_create_repository: 新版本库
label_project_more: 更多
project_module_news: 新闻
@ -112,6 +114,7 @@ zh:
label_project_overview: "项目简介"
label_expend_information: 展开更多信息
label_project_create: "新建了项目"
lable_project_rep_create: 创建
#
# 项目托管平台

View File

@ -0,0 +1,22 @@
#coding=utf-8
namespace :rep_fault do
desc "update fault rep"
task :rep_update => :environment do
Project.all.each do |project|
if project.repositories.count > 0
unless Repository.where("project_id =? and type = ?",project, "Repository::Gitlab").blank?
project.repositories.each do |repository|
repository.update_attributes(:is_default => false)
end
end
end
end
end
desc "update ossean's data"
task :update_type => :environment do
repository = Repository.find(400)
repository.update_attributes(:type => "Repository::Git")
end
end

View File

@ -553,6 +553,7 @@ a:hover.member_btn{ background:#329cbd;}
.pro_table tr td{ height:30px;}
.pro_table_tit{ text-align:center; font-weight:bold;}
.pro_table_on{ background:#f0fbff; }
.pro_table_on_forge{ background: #EAEAEA; }
.pro_st_edit_issues{ display:none; margin-top:20px;}
.pro_st_edit_issues ul li{ margin-bottom:10px;}
.pro_st_edit_ban{ display:none; margin-top:20px;}

View File

@ -71,6 +71,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.ml45{ margin-left:45px;}
.ml55{ margin-left:55px;}
.ml30{ margin-left:30px;}
.ml38{ margin-left:38px;}
.ml60{ margin-left:60px;}
.ml80{ margin-left:80px;}
.ml90{ margin-left:90px;}
@ -133,6 +134,7 @@ h4{ font-size:14px; color:#3b3b3b;}
.w265{ width: 265px;}
.w270{ width: 270px;}
.w350 {width:350px;}
.w362 {width:362px;}
.w430{ width:470px;}
.w520{ width:520px;}
.w543{ width:543px;}

View File

@ -275,4 +275,13 @@ li.commit .commit-row-info a {
}
li.commit .commit-row-info .committed_ago {
display: inline-block;
}
.rep_history_title{
font-weight: bold;
font-size: 13px;
color: #7F7F7F;
padding-bottom: 10px;
}
.rep_history_grey{
color: #7F7F7F;
}