Merge branch 'dev_newproject' into develop

This commit is contained in:
huang 2016-12-16 16:13:26 +08:00
commit c477d15fae
14 changed files with 139 additions and 104 deletions

View File

@ -5,7 +5,7 @@ class PullRequestsController < ApplicationController
before_filter :authorize_logged
before_filter :find_project_and_repository
before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request, :pull_request_comments, :create_pull_request_comment, :compare_pull_request]
before_filter :member_allowed, :only => [:new, :create]
before_filter :member_allowed, :only => [:new, :create, :create_pull_request_comment]
before_filter :manager_allowed, :only => [:accept_pull_request]
layout "base_projects"
@ -188,15 +188,21 @@ class PullRequestsController < ApplicationController
# @return [Gitlab::ObjectifiedHash]
def accept_pull_request
begin
status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
@status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
# 接受后,给用户发消息
send_message_to_author(@project.id, status.author.try(:username), params[:id], 2)
send_message_to_author(@project.id, @status.author.try(:username), params[:id], 2)
respond_to do |format|
format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)}
format.js{redirect_to project_pull_request_path(@status.id, :project_id => @project.id)}
end
rescue Gitlab::Error::Forbidden => e
@message = l(:label_pull_request_forbidden)
rescue Gitlab::Error::DataNotAccepted => e
@message = l(:label_pull_request_datanotaccepted)
rescue Gitlab::Error::NotFound => e
@message = l(:label_pull_request_notfound)
rescue Exception => e
@message = e.message
puts e
end
end

View File

@ -82,10 +82,16 @@ module ApplicationHelper
user.nil? ? User.find(2) : user
end
# 通过邮件查找用户,能查到返回用户,否则返回邮件地址
def user_by_mail mail
user = User.find_by_mail(mail)
user.nil? ? mail : user.try(:show_name)
# 通过登录名查找用户,能查到返回用户姓名,否则返回登录名
def link_to_user_login login, css_class
user = User.find_by_login(login)
user = user.nil? ? login : user
if user.is_a?(User)
name = user.show_name
link_to name, {:controller=> 'users', :action => 'show', id: user.id}, :class => css_class, :target => "_blank"
else
"<a class='#{css_class}'>#{h(user.to_s)}</a>".html_safe
end
end
def link_to_user_mail(mail, css_class)
@ -95,7 +101,7 @@ module ApplicationHelper
name = user.show_name
link_to name, {:controller=> 'users', :action => 'show', id: user.id}, :class => css_class, :target => "_blank"
else
"<a class='#{css_class}'>#{h(user.to_s)}</a>".html_safe
"<a class='#{css_class}' title='#{user.to_s}'>#{h(user.to_s)}</a>".html_safe
end
end

View File

@ -27,30 +27,7 @@
<%#= wikitoolbar_for 'issue_description' %>
<% end %>
</li>
<li class="fl">
<% if @issue.safe_attribute? 'tracker_id' %>
<label class="label mt3"><span class="c_red f12">*</span>&nbsp;类型&nbsp;&nbsp;:&nbsp;</label>
<%= f.select :tracker_id, @issue.project.trackers.collect { |t| [t.name, t.id] },
{:required => true, :no_label => true},
#:onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')",
:class => "w110" %>
<% end %>
</li>
<li class="fl ml41">
<label class="label mt3"><span class="c_red f12">*</span><%= l(:field_status) %></label>
<%# if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %>
<%= f.select :status_id, (@allowed_statuses.collect { |p| [p.name, p.id] }),
{:no_label => true},
:class => "w110" %>
</li>
<li class="fl ml41">
<label class="label mt3"><span class="c_red f12">*</span><%= l(:field_priority) %></label>
<% if @issue.safe_attribute? 'priority_id' %>
<%= f.select :priority_id, (@priorities.collect { |p| [p.name, p.id] }),
{:required => true, :no_label => true}, :disabled => !@issue.leaf?,
:class => "w110" %>
<% end %>
</li>
<li class="clear">
<label class="label"><%= l(:label_attachment_plural) %></label>
<%= render :partial => 'attachments/form', :locals => {:container => @issue} %>
@ -75,66 +52,90 @@
<% end %>
</li>
<li class="clear" id="versions_assigned_id">
<span class="fl mt6 mr10">指派给</span>
<% if @issue.safe_attribute? 'assigned_to_id' %>
<%= f.select :assigned_to_id, assigned_options_for_select(@issue.assignable_users, @issue.assigned_to),
{:required => @issue.required_attribute?('assigned_to_id'), :no_label => true},
{:onchange => "change_assigned_tip();",:class => "w150"} %>
{:onchange => "change_assigned_tip();",:class => "w160 fl"} %>
<% end %>
</li>
<li class="clear" id="assigned_to_tips">
<%= @issue.assigned_to.nil? ? "未指派" : "已指派" %>
<li class="clear">
<span class="fl mt6 mr12">类&nbsp;&nbsp;&nbsp;型</span>
<% if @issue.safe_attribute? 'tracker_id' %>
<%= f.select :tracker_id, @issue.project.trackers.collect { |t| [t.name, t.id] },{:required => true, :no_label => true},
#:onchange => "updateIssueFrom('#{escape_javascript project_issue_form_path(@project, :id => @issue, :format => 'js')}')",
:class => "fl", :style => "width:160px;padding-left:0px;" %>
<% end %>
</li>
<li class="clear">
<span class="fl mt6 mr12">状&nbsp;&nbsp;&nbsp;态</span>
<%# if @issue.safe_attribute?('status_id') && @allowed_statuses.present? %>
<%= f.select :status_id, (@allowed_statuses.collect { |p| [p.name, p.id] }),
{:no_label => true},
:class => "fl", :style => "width:160px;padding-left:0px;" %>
</li>
<li class="clear">
<span class="fl mt6 mr10"><%= l(:field_priority) %></span>
<% if @issue.safe_attribute? 'priority_id' %>
<%= f.select :priority_id, (@priorities.collect { |p| [p.name, p.id] }),
{:required => true, :no_label => true}, :disabled => !@issue.leaf?,
:class => "w160 fl" %>
<% end %>
</li>
<li class="clear" >
<%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version),
{:include_blank => true, :required => @issue.required_attribute?('fixed_version_id'), :no_label => true},
{:onchange => "change_milestone_tip();", :class => "w150"} %>
</li>
<li class="clear" id="milestone_option_tips">
<%= @issue.fixed_version.nil? ? "未选择里程碑" : "已选择里程碑" %>
<% if params[:action] == "new" %>
<%= link_to "", new_project_version_path(@project, :is_issue => true, :issue_project_id => @project.id), :class => "pic_add mt5 ml5 fr", :remote => true %>
<% end %>
</li>
<li class="clear" style="border:1px solid #c8c8c8;">
<% if @issue.safe_attribute? 'start_date' %>
<%= f.text_field :start_date, :size => 22, :disabled => !@issue.leaf?, :no_label => true,
:required => @issue.required_attribute?('start_date'), :onchange => "issue_start_date_change();",
:class => "fl calendar_input", :style => "width:170px;" %>
<%= calendar_for('issue_start_date', 'start_date') if @issue.leaf? %>
<% end %>
</li>
<li class="clear" id="option_start_date_tips">
<%= @issue.start_date.nil? ? "未选择开始日期" : "已选择开始日期" %>
</li>
<li class="clear" style="border:1px solid #c8c8c8;">
<label class="label02" ></label>
<% if @issue.safe_attribute? 'due_date' %>
<%= f.text_field :due_date, :size => 22, :disabled => !@issue.leaf?, :no_label => true,
:required => @issue.required_attribute?('due_date'), :onchange => "issue_end_date_change();",
:class => "fl calendar_input",:style => "width: 170px;", :placeholder => "请选择结束日期" %>
<%= calendar_for('issue_due_date', 'start_date') if @issue.leaf? %>
<% end %>
</li>
<li class="clear " id="option_end_date_tips">
<%= @issue.due_date.nil? ? "未选择结束日期" : "已选择结束日期" %>
<span class="fl mt6 mr10">里程碑</span>
<%= f.select :fixed_version_id, version_options_for_select(@issue.assignable_versions, @issue.fixed_version),
{:include_blank => true, :required => @issue.required_attribute?('fixed_version_id'), :no_label => true},
{:onchange => "change_milestone_tip();", :class => "w160 fl"} %>
</li>
<li class="clear">
<% if @issue.safe_attribute? 'estimated_hours' %>
<%= f.text_field :estimated_hours, :size => 22, :disabled => !@issue.leaf?, :no_label => true,
:required => @issue.required_attribute?('estimated_hours'), :placeholder => "请填写预计工时" %>
<% end %>
<label class="fl mt6 mr12">开&nbsp;&nbsp;&nbsp;始</label>
<label class=" fl" style="border:1px solid #c8c8c8;display: inline-block;">
<% if @issue.safe_attribute? 'start_date' %>
<%= f.text_field :start_date, :size => 22, :disabled => !@issue.leaf?, :no_label => true,
:required => @issue.required_attribute?('start_date'), :onchange => "issue_start_date_change();",
:class => "fl issues_calendar_input",
:style => "height:28px;border-left:none;border-top:none;border-bottom:none;width:124px;",
:placeholder => "请选择开始日期" %>
<%= calendar_for('issue_start_date', 'start_date') if @issue.leaf? %>
<% end %>
</label>
</li>
<li class="clear"><%= l(:field_estimated_hours) %></li>
<li class="clear">
<!--<label class="label02" ></label>-->
<label class="fl mt6 mr12">结&nbsp;&nbsp;&nbsp;束</label>
<label class=" fl" style="border:1px solid #c8c8c8;display: inline-block;">
<% if @issue.safe_attribute? 'due_date' %>
<%= f.text_field :due_date, :size => 10, :disabled => !@issue.leaf?, :no_label => true,
:required => @issue.required_attribute?('due_date'), :onchange => "issue_end_date_change();",
:class => "issues_calendar_input fl",
:style => "height:28px;border-left:none;border-top:none;border-bottom:none;width:124px;",
:placeholder => "请选择结束日期" %>
<%= calendar_for('issue_due_date', 'start_date') if @issue.leaf? %>
<% end %>
</label>
</li>
<li class="clear">
<span class="fl mt6 mr12">工&nbsp;&nbsp;&nbsp;时</span>
<% if @issue.safe_attribute? 'estimated_hours' %>
<%= f.text_field :estimated_hours, :disabled => !@issue.leaf?, :no_label => true,
:required => @issue.required_attribute?('estimated_hours'), :placeholder => "请填写预计工时",
:class => "fl", :style => "width:153px;" %>
<% end %>
</li>
<li class="clear">
<span class="fl mt6 mr10">完成度</span>
<% if @issue.safe_attribute?('done_ratio') && @issue.leaf? && Issue.use_field_for_done_ratio? %>
<%= f.select :done_ratio, ((0..10).to_a.collect { |r| ["#{r*10} %", r*10] }),
{:required => @issue.required_attribute?('done_ratio'), :no_label => true},
:onchange => "PrecentChange(this.value)",
:class => "w150" %>
:class => "w160 fl" %>
<% end %>
</li>
<li class="clear">完成度</li>
<% if @project.gpid %>
<%#= hidden_field_tag @issue_commit_ids %>
<input value="" name="commit_ids" id="commit_ids" type="hidden">
@ -162,6 +163,28 @@
</ul>
<% end %>
<script>
function change_assigned_tip() {
if( document.getElementById('issue_assigned_to_id').options[document.getElementById('issue_assigned_to_id').selectedIndex].value == 0 ){
$('#assigned_to_tips').html("未指派");
}
else{
$('#assigned_to_tips').html("已指派")};
}
function change_milestone_tip(version_id){
if( document.getElementById('issue_fixed_version_id').options[document.getElementById('issue_fixed_version_id').selectedIndex].value == 0 ){
$('#milestone_option_tips').html("未选择里程碑")}
else{
$('#milestone_option_tips').html("已选择里程碑")
};
}
function issue_start_date_change(){
$('#option_start_date_tips').html("已选择开始日期");
}
function issue_end_date_change() {
$('#option_end_date_tips').html("已选择结束日期");
}
function issue_create(){
var issue_commit_ids = $("#issue_commit_ids .commit_id_value");
var str = "";
@ -195,26 +218,6 @@
})
}
function change_assigned_tip() {
if( document.getElementById('issue_assigned_to_id').options[document.getElementById('issue_assigned_to_id').selectedIndex].value == 0 ){
$('#assigned_to_tips').html("未指派");
}
else{
$('#assigned_to_tips').html("已指派")};
}
function change_milestone_tip(version_id){
if( document.getElementById('issue_fixed_version_id').options[document.getElementById('issue_fixed_version_id').selectedIndex].value == 0 ){
$('#milestone_option_tips').html("未选择里程碑")}
else{
$('#milestone_option_tips').html("已选择里程碑")
};
}
function issue_start_date_change(){
$('#option_start_date_tips').html("已选择开始日期");
}
function issue_end_date_change() {
$('#option_end_date_tips').html("已选择结束日期");
}
// 里程碑添加默认选项
$("#issue_fixed_version_id option[value='']").remove();

View File

@ -64,6 +64,11 @@
<span class="pro_new_conbox_rightspan fl ml10"><%= format_date(@issue.start_date) %></span>
</li>
<% end %>
<% unless @issue.disabled_core_fields.include?('due_date') %>
<li class="clear"><span class="pro_new_conbox_leftspan fl">结束日期</span>
<span class="pro_new_conbox_rightspan fl ml10"><%= format_date(@issue.due_date) %></span>
</li>
<% end %>
<% unless @issue.disabled_core_fields.include?('estimated_hours') %>
<li class="clear"><span class="pro_new_conbox_leftspan fl">预计工时(H)</span>
<span class="pro_new_conbox_rightspan fl ml10"><%= l_hours(@issue.estimated_hours) %></span>

View File

@ -3,7 +3,11 @@
<%= form_tag(url_for(:controller => 'pull_requests', :action => 'create_pull_request_comment', :project_id => @project.id), :id => 'pull_request_comment_form', :method => "post", :remote => true) do %>
<textarea id="pull_request_comment" name="pull_request_comment" class="pullreques_reply_textarea" style="padding-left: 0px;"></textarea>
<span id ="pr_comment_tip" class="fontGrey2 c_red" style="display: none">内容不能为空</span>
<a href="javascript:void(0);" class="btn btn-blue fr" onclick="pull_request_commit()">留言</a>
<% if User.current.member_of?(@project) %>
<a href="javascript:void(0);" class="btn btn-blue fr" onclick="pull_request_commit()">留言</a>
<% else %>
<a class="btn btn-grey fr" >留言</a>
<% end %>
<% end %>
</div>
<ul class="pullreques_reply_list">
@ -12,7 +16,7 @@
<%= link_to image_tag(url_to_avatar(get_user_by_login_and(comment.author.try(:username))), :width => "43", :height => "43", :class => "pullreques_reply_user_img fl mr15"), user_path(get_user_by_login_and(comment.author.try(:username))), :alt => "用户头像", :target => "_blank", :class => "fl" %>
<div class="sy_teachers_txt fl ">
<p class="clear mb5">
<%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "pullreques_reply_name fl", :target => "_blank" %>
<%= link_to_user_login(comment.author.try(:username), "pullreques_reply_name fl") %>
<span class="fl ml15 c_grey"><%= time_tag(comment.created_at) %>前</span>
</p>
<p class="pullreques_reply_txt"><%= comment.note %></p>

View File

@ -8,7 +8,7 @@
<% commits.each do |commit| %>
<li class="clear">
<span class="fl c_grey ml15 "><%= time_tag(commit.created_at) %>前</span>
<%= link_to get_user_by_mail(commit.author_email).show_name, user_path(get_user_by_mail(commit.author_email)), :target => "_blank", :class => "pullreques_pull_name fl ml10" %>
<%= link_to_user_mail(commit.author_email, "pullreques_pull_name fl ml10") %>
<p class="pullreques_pull_txt ml10 fl"><%= commit.title %></p>
<%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank", :class => "fr mr15 c_grey" %>
</li>

View File

@ -12,7 +12,7 @@
<%= link_to "", project_pull_request_path(request.id, :project_id => @project.id), :class => "issues_icons_mes fr mr5 ml5" %>
</div>
<div class="c_grey clear mt5">
<p class="fl">由 <%= link_to get_user_by_login_and(request.author.try(:username)).try(:show_name), user_path(get_user_by_login_and(request.author.try(:username))), :class => "linkBlue2" %> 创建于<%= time_tag(request.created_at) %>前</p>
<p class="fl">由 <%= link_to_user_login(request.author.try(:username), "linkBlue2") %> 创建于<%= time_tag(request.created_at) %>前</p>
<span class="fl ml10"><%= time_tag(request.updated_at) %>前更新</span>
<p class="fr"><%#= find_gitlab_project(request.source_project_id)+"/"+request.source_branch %><span class="c_grey02 ml10 mr10">合并到</span><%#= find_gitlab_project(request.target_project_id)+"/"+request.target_branch %></p>
</div>

View File

@ -19,7 +19,7 @@
<p><%= @request.description %></p>
</div>
<div class="c_grey clear mt5">
<p class="fl">由 <%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "linkBlue2" %>于 <%= format_time(@request.created_at) %> 创建</p>
<p class="fl">由 <%= link_to_user_login(@request.author.try(:username), "linkBlue2") %>于 <%= format_time(@request.created_at) %> 创建</p>
<span class="fl ml10">最近更新:<%= format_time(@request.updated_at) %></span>
<p class="fr">
<%= find_gitlab_project(@request.source_project_id)+"/"+@request.source_branch %><span class="c_grey02 ml10 mr10">合并到</span><%= find_gitlab_project(@request.target_project_id)+"/"+@request.target_branch %>
@ -34,7 +34,9 @@
改动已合并至 <%= @request.target_branch %> 分支
</div>
<% else %>
<%= render "show_container" %>
<div id="unmerged_tip">
<%= render "show_container" %>
</div>
<% end %>

View File

@ -6,7 +6,7 @@
<div class="alert alert-orange mb15 ">
项目分支 <%= @request.source_branch %> 和 <%= @request.target_branch %> 似乎没有差异,请将新改动提交至源分支或者切换到其它目标分支
</div>
<% elsif !@request.merge_when_build_succeeds %>
<% elsif @request.try(:merge_status) == "cannot_be_merged" %>
<div class="alert alert-orange mb15 ">
Pull Request中存在冲突请先解决冲突或者手动进行合并。
</div>

View File

@ -1,2 +1,4 @@
$("#create_pull_request_error").html('<%= escape_javascript(render :partial => "pull_requests/error_message") %>');

View File

@ -510,4 +510,5 @@ zh:
label_pull_request_conflic: 您创建的Pull Request尚未被管理员接受或者关闭不能重新创建
label_pull_request_forbidden: 您没有权限进行该操作
label_pull_request_notfound: 您操作的页面不存在或者已被删除
label_pull_request_notfound: 您操作的页面不存在或者已被删除
label_pull_request_datanotaccepted: Pull Request中存在冲突请先解决冲突或者手动进行合并

View File

@ -27,6 +27,9 @@ module Gitlab
# Raised when API endpoint returns the HTTP status code 405.
class MethodNotAllowed < Error; end
# Raised when API endpoint returns the HTTP status code 406.
class DataNotAccepted < Error; end
# Raised when API endpoint returns the HTTP status code 409.
class Conflict < Error; end

View File

@ -68,6 +68,7 @@ module Gitlab
when 403; raise Error::Forbidden.new error_message(response)
when 404; raise Error::NotFound.new error_message(response)
when 405; raise Error::MethodNotAllowed.new error_message(response)
when 406; raise Error::DataNotAccepted.new error_message(response)
when 409; raise Error::Conflict.new error_message(response)
when 500; raise Error::InternalServerError.new error_message(response)
when 502; raise Error::BadGateway.new error_message(response)

View File

@ -154,6 +154,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.mr5{ margin-right:5px;}
.mr8{ margin-right:8px;}
.mr10{ margin-right:10px;}
.mr12{ margin-right:12px;}
.mr15 {margin-right:15px;}
.mr18 {margin-right:18px;}
.mr20{ margin-right:20px;}
@ -254,6 +255,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/
.w140{ width:140px;}
.w145{ width:145px;}
.w150{ width:150px;}
.w160{width:160px !important;}
.w170{width:170px;}
.w180{width:180px;}
.w186{ width:186px;}