diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 191465003..367f14dd9 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -22,9 +22,9 @@ class IssuesController < ApplicationController before_filter :authorize1, :only => [:show] before_filter :find_issue, :only => [:show, :edit, :update,:add_journal, :add_journal_in_org] before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] - before_filter :find_project, :only => [:new, :create, :update_form] + before_filter :find_project, :only => [:new, :create, :update_form, :issue_commits] #before_filter :authorize, :except => [:index, :show] - before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org,:delete_journal,:reply,:add_reply] + before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org,:delete_journal,:reply,:add_reply, :issue_commits] before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] @@ -60,12 +60,14 @@ class IssuesController < ApplicationController # issue和代码提交id关联模块 --> over # 获取某个项目的commit_ids def issue_commits - project = Project.find(@issue.project_id) begin - g = Gitlab.commits(project.gpid) + return render_404 if @project.gpid.nil? + g = Gitlab.client g_project = g.project(project.gpid) @rev = params[:rev].nil? ? g_project.default_branch : params[:rev] @commits = g.g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s, ref_name:rev) + @commits_count = params[:commit_count].to_i + @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] rescue Exception => e puts e end diff --git a/app/models/issue.rb b/app/models/issue.rb index 46a42cb34..b46e29104 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -56,6 +56,8 @@ class Issue < ActiveRecord::Base has_one :praise_tread_cache, as: :object, dependent: :destroy # ForgeMessage虚拟关联(多态) has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy + # 该关联不能关联删除,因为commit记录没有存在Trustie数据库中 + has_many :commit_issueses has_many :at_messages, class_name: 'AtMessage', as: :at_message ,:dependent => :destroy diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index 9208638c4..bc5063f19 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -135,7 +135,9 @@ <% end %>
  • 完成度
  • -
  • 关联Commit<%= link_to "+".html_safe, issue_commits_issues_path %>
  • + <% if @project.gpid %> +
  • 关联Commit<%= link_to "+".html_safe, issue_commits_issues_path(:project_id => @project), :remote => true %>
  • + <% end %> <% end %>