diff --git a/Gemfile b/Gemfile index 58ccbc011..72bd03c7b 100644 --- a/Gemfile +++ b/Gemfile @@ -50,10 +50,10 @@ gem 'elasticsearch-model' gem 'elasticsearch-rails' #rails 3.2.22.2 bug - gem "test-unit", "~>3.0" + # gem "test-unit", "~>3.0" ### profile - gem 'oneapm_rpm' + # gem 'oneapm_rpm' group :development do gem 'grape-swagger' diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 72a1132c9..48a3814da 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -101,8 +101,16 @@ class PullRequestsController < ApplicationController 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 @@ -331,6 +339,10 @@ class PullRequestsController < ApplicationController end end + 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 diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index aebc82b14..86c04e9e4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -90,51 +90,60 @@ class UsersController < ApplicationController # order 排序条件 # subject 主题:搜索用(注意:搜索和列表调用同一方法,通过参数或者remote区分) def user_issues - @subject = params[:subject] - # author_id = params[:author_id] - params[:assigned_to_id].to_i == 0 ? @assigned_to = nil : @assigned_to = params[:assigned_to_id].to_i - params[:author_id].to_i == 0 ? author_id = nil : author_id = params[:author_id].to_i - params[:project_id].to_i == 0 ? @project_id = nil : @project_id = params[:project_id] - if @project_id.nil? - if @assigned_to.nil? - if author_id.nil? - @issues = Issue.where("(author_id =? or assigned_to_id =? ) and subject like ?", - @user.id , @user.id, "%#{@subject}%").order('updated_on desc') + @subject = params[:subject] + # author_id = params[:author_id] + params[:assigned_to_id].to_i == 0 ? @assigned_to = nil : @assigned_to = params[:assigned_to_id].to_i + params[:author_id].to_i == 0 ? author_id = nil : author_id = params[:author_id].to_i + params[:project_id].to_i == 0 ? @project_id = nil : @project_id = params[:project_id] + if @project_id.nil? + if @assigned_to.nil? + if author_id.nil? + @issues = Issue.where("(author_id =? or assigned_to_id =? ) and subject like ?", + @user.id , @user.id, "%#{@subject}%").order('updated_on desc') + else + @issues = Issue.where("author_id =? and subject like ?", + author_id , "%#{@subject}%").order('updated_on desc') + end else - @issues = Issue.where("author_id =? and subject like ?", - author_id , "%#{@subject}%").order('updated_on desc') + @issues = Issue.where("assigned_to_id =? and subject like ?", @assigned_to, "%#{@subject}%").order('updated_on desc') end - else - @issues = Issue.where("assigned_to_id =? and subject like ?", @assigned_to, "%#{@subject}%").order('updated_on desc') - end - else - if @assigned_to.nil? - if author_id.nil? - @issues = Issue.where("(author_id =? or assigned_to_id =? ) and project_id=? and subject like ?", - (author_id ? author_id : @user.id) , @user.id, @project_id, "%#{@subject}%").order('updated_on desc') - else - @issues = Issue.where("author_id =? and project_id=? and subject like ?", - author_id , @project_id, "%#{@subject}%").order('updated_on desc') - end else - @issues = Issue.where("assigned_to_id =? and project_id=? and subject like ?", - @assigned_to, @project_id, "%#{@subject}%").order('updated_on desc') + if @assigned_to.nil? + if author_id.nil? + @issues = Issue.where("(author_id =? or assigned_to_id =? ) and project_id=? and subject like ?", + (author_id ? author_id : @user.id) , @user.id, @project_id, "%#{@subject}%").order('updated_on desc') + else + @issues = Issue.where("author_id =? and project_id=? and subject like ?", + author_id , @project_id, "%#{@subject}%").order('updated_on desc') + end + else + @issues = Issue.where("assigned_to_id =? and project_id=? and subject like ?", + @assigned_to, @project_id, "%#{@subject}%").order('updated_on desc') + end end - end - @issues_filter = Issue.where("author_id =? or assigned_to_id =?", (author_id ? author_id : @user.id) , @user).order('updated_on desc') - @issues_assigned_count = Issue.where("assigned_to_id =? and subject like ?", @user.id, "%#{@subject}%").count - @issues_author_count = Issue.where("author_id =? and subject like ?", @user.id, "%#{@subject}%").count - @issue_open_count = Issue.where(" (author_id =? or assigned_to_id =?) and status_id in (1,2,3,4,6)", (author_id ? author_id : @user.id) , @user).count - @issue_close_count = Issue.where("(author_id =? or assigned_to_id =?) and status_id = 5", (author_id ? author_id : @user.id) , @user.id).count - @issue_count = @issues.count - @limit = 10 - @is_remote = true - @issue_pages = Paginator.new @issue_count, @limit, params['page'] || 1 - @offset ||= @issue_pages.offset - @issues = paginateHelper @issues, @limit + @issues_filter = Issue.where("author_id =? or assigned_to_id =?", (author_id ? author_id : @user.id) , @user).order('updated_on desc') + @issues_assigned_count = Issue.where("assigned_to_id =? and subject like ?", @user.id, "%#{@subject}%").count + @issues_author_count = Issue.where("author_id =? and subject like ?", @user.id, "%#{@subject}%").count + @issue_open_count = Issue.where(" (author_id =? or assigned_to_id =?) and status_id in (1,2,3,4,6)", (author_id ? author_id : @user.id) , @user).count + @issue_close_count = Issue.where("(author_id =? or assigned_to_id =?) and status_id = 5", (author_id ? author_id : @user.id) , @user.id).count + + # 导出excel的issues + @excel_issues = @issues + + @issue_count = @issues.count + @limit = 10 + @is_remote = true + @issue_pages = Paginator.new @issue_count, @limit, params['page'] || 1 + @offset ||= @issue_pages.offset + @issues = paginateHelper @issues, @limit + respond_to do |format| format.html{render :layout => 'static_base'} + format.xls{ + filename = "我的_#{l(:label_issue_list_xls)}.xls" + send_data(issue_list_xls(@excel_issues), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename)) + } format.api format.js end diff --git a/app/models/forge_message.rb b/app/models/forge_message.rb index 8bf754719..bc514025e 100644 --- a/app/models/forge_message.rb +++ b/app/models/forge_message.rb @@ -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 diff --git a/app/models/pull_request.rb b/app/models/pull_request.rb index f40397cf0..ec13ff16b 100644 --- a/app/models/pull_request.rb +++ b/app/models/pull_request.rb @@ -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 diff --git a/app/views/pull_requests/_form.html.erb b/app/views/pull_requests/_form.html.erb index d76c3e8a8..0aa2a1177 100644 --- a/app/views/pull_requests/_form.html.erb +++ b/app/views/pull_requests/_form.html.erb @@ -112,4 +112,4 @@ var defaultBranch = $("#targetBranch option:first-child").val(); $("#targetBranch").val(defaultBranch); }); - \ No newline at end of file + diff --git a/app/views/pull_requests/_pull_requests_list.html.erb b/app/views/pull_requests/_pull_requests_list.html.erb index feb3cdecf..d5892b4de 100644 --- a/app/views/pull_requests/_pull_requests_list.html.erb +++ b/app/views/pull_requests/_pull_requests_list.html.erb @@ -12,7 +12,7 @@ <%= link_to "", project_pull_request_path(request.id, :project_id => @project.id), :class => "issues_icons_mes fr mr5 ml5" %>
-

由 <%= link_to request.author.try(:username), user_path(get_user_by_login_and(request.author.try(:username))), :class => "linkBlue2" %> 创建于<%= time_tag(request.created_at) %>前

+

由 <%= 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) %>前

<%= time_tag(request.updated_at) %>前更新

<%= find_gitlab_project(request.source_project_id)+"/"+request.source_branch %>合并到<%= find_gitlab_project(request.target_project_id)+"/"+request.target_branch %>

diff --git a/app/views/users/_all_issue_list.html.erb b/app/views/users/_all_issue_list.html.erb index cc33fc95d..0e7ccfca2 100644 --- a/app/views/users/_all_issue_list.html.erb +++ b/app/views/users/_all_issue_list.html.erb @@ -10,7 +10,9 @@
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb index 159da2789..b1936e19b 100644 --- a/app/views/users/_user_message_course.html.erb +++ b/app/views/users/_user_message_course.html.erb @@ -28,8 +28,15 @@ <% end %> <% if ma.course_message_type == "Comment" && ma.course_message %>