Merge branch 'dai_ao' into develop
This commit is contained in:
commit
b9ef98bc19
|
@ -92,13 +92,21 @@ class PullRequestsController < ApplicationController
|
|||
if compare_pull_request(source_branch, target_project_id, target_branch)
|
||||
# 如果传送了目标项目ID即向fork源项目发送请求
|
||||
# if params[:forked_project_id] && params[:source_project] == "forked_project_name"
|
||||
if params[:target_project_id].to_i != @project.id
|
||||
if !params[:target_project_id].blank?
|
||||
target_project_id = params[:forked_project_id].to_i
|
||||
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch, :target_project_id => target_project_id)
|
||||
@fork_project_name = Project.find(params[:target_project_id]).try(:name)
|
||||
@fork_pr_message = true if @fork_project_name
|
||||
# 发送消息
|
||||
#send_message(User.current.id, target_project_id, title)
|
||||
# 创建Trustie数据
|
||||
#PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => target_project_id)
|
||||
else
|
||||
request = @g.create_merge_request(@project.gpid, title, User.current.gid, :description => description, :source_branch => source_branch, :target_branch => target_branch)
|
||||
# 发送消息
|
||||
#send_message(User.current.id, @project.id, title)
|
||||
# 创建Trustie数据
|
||||
#PullRequest.create(:pull_request_id => request.id, :user_id => User.current.id, :status => 1, :project_id => @project.id)
|
||||
respond_to do |format|
|
||||
format.js{redirect_to project_pull_request_path(request.id, :project_id => @project.id)}
|
||||
end
|
||||
|
@ -287,6 +295,10 @@ class PullRequestsController < ApplicationController
|
|||
end
|
||||
|
||||
private
|
||||
def send_message user_id, project_id, title
|
||||
self.forge_acts << ForgeMessage.new(:user_id => user_id, :project_id => project_id, :title => title)
|
||||
end
|
||||
|
||||
def authorize_logged
|
||||
if !User.current.logged?
|
||||
redirect_to signin_path
|
||||
|
|
|
@ -75,7 +75,7 @@ module ApplicationHelper
|
|||
# 通过系统外部用户名查找用户,如果用户不存在则用邮箱替换
|
||||
def get_user_by_login_and login
|
||||
user = User.find_by_login(login)
|
||||
user.nil? ? User.find(2) : user
|
||||
(user.nil? || login == "root") ? User.find(2) : user
|
||||
end
|
||||
|
||||
# 重置user_path,目的是将id转换成用户名
|
||||
|
|
|
@ -6,7 +6,7 @@ class ForgeMessage < ActiveRecord::Base
|
|||
belongs_to :forge_message ,:polymorphic => true
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
|
||||
has_many :message_alls, :class_name => 'MessageAll', :as => :message, :dependent => :destroy
|
||||
|
||||
validates :user_id,presence: true
|
||||
validates :project_id,presence: true
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class PullRequest < ActiveRecord::Base
|
||||
attr_accessible :gpid, :pull_request_id, :user_id
|
||||
# status 1:创建 2:接受 3:重新打开 4:关闭
|
||||
attr_accessible :gpid, :pull_request_id, :user_id, :status
|
||||
validates_uniqueness_of :pull_request_id
|
||||
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
|
||||
end
|
||||
|
|
|
@ -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 User.find(request.author.id).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 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>
|
||||
<span class="fl ml10"><%= time_tag(request.updated_at) %>前更新</span>
|
||||
<p class="fr"><%= @project.name+"/"+request.source_branch %><span class="c_grey02 ml10 mr10">合并到</span><%= request.target_branch %></p>
|
||||
</div>
|
||||
|
|
|
@ -194,4 +194,24 @@
|
|||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<!--
|
||||
<%# if ma.forge_message_type == "PullRequest" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<a href="javascript:void(0);">
|
||||
<%#=link_to image_tag(url_to_avatar(ma.forge_message.author), :width => "30", :height => "30"), user_path(ma.forge_message.author), :target => '_blank' %>
|
||||
</a>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%#=link_to User.find(ma.forge_message.author).show_name, user_path(ma.forge_message.author),
|
||||
:class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
|
||||
<span class="<%#= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">创建了PullRequest:</span>
|
||||
</li>
|
||||
<li class="homepageNewsContent fl">
|
||||
<%#= link_to "#{ma.forge_message.commented.title}",
|
||||
{:controller => 'news', :action => 'show', :id => ma.forge_message.commented.id },:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
|
||||
</li>
|
||||
<li class="homepageNewsTime fl"><%#= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
<%# end %>-->
|
||||
<% end %>
|
|
@ -0,0 +1,5 @@
|
|||
class AddStatusToPullRequests < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :pull_requests, :status, :integer, :default => false
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddProjectIdToPullRequests < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :pull_requests, :project_id, :integer
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue