diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 23f8e0711..22efcf775 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, :issue_commits, :commit_for_issue] + before_filter :find_project, :only => [:new, :create, :update_form, :issue_commits, :commit_for_issue, :issue_commit_delete] #before_filter :authorize, :except => [:index, :show] - before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org,:delete_journal,:reply,:add_reply, :issue_commits, :commit_for_issue] + before_filter :authorize, :except => [:index,:add_journal, :add_journal_in_org,:delete_journal,:reply,:add_reply, :issue_commits, :commit_for_issue, :issue_commit_delete] before_filter :find_optional_project, :only => [:index] before_filter :check_for_default_issue_status, :only => [:new, :create] @@ -80,10 +80,23 @@ class IssuesController < ApplicationController end end + # 选择对应的Commit def commit_for_issue history_commit_ids = params[:issue_commit_ids] @issue_commit_ids = (history_commit_ids.blank? ? params[:checkbox1] : params[:checkbox1] | history_commit_ids).uniq end + + def issue_commit_delete + commit_id = params[:commit_id].split(",") + issue_commit_ids = params[:issue_commit_ids] + # issue_id存在则为issue详情或者编辑的时候,否则为新建Issue + # 编辑和详情的时候需要在数据库中删除记录,新建的时候在内存中删除 + if params[:issue_id] + commit_issue = CommitIssues.where(:commit_id => commit_id, :issue_id => params[:issue_id], :project_id => @project.id).first + commit_issue.delete if commit_issue + end + @issue_commit_ids = issue_commit_ids - commit_id + end # over def index @@ -845,7 +858,6 @@ class IssuesController < ApplicationController # 更新issue状态时,journal表产生记录,返回@current_journal @issue.init_journal(User.current) - issue_attributes = params[:issue] if issue_attributes && params[:conflict_resolution] case params[:conflict_resolution] @@ -860,18 +872,18 @@ class IssuesController < ApplicationController end end - senduser = User.find(params[:issue][:assigned_to_id]) - - if senduser.id != User.current.id && @issue.assigned_to_id != params[:issue][:assigned_to_id].to_i - issue_id = @issue.id - issue_title = params[:issue][:subject] - priority_id = params[:issue][:priority_id] - ps = ProjectsService.new - ps.send_wechat_project_issue_notice senduser,@issue.project,issue_id,issue_title,priority_id + if params[:action] == "update" + senduser = User.find(params[:issue][:assigned_to_id]) + if senduser.id != User.current.id && @issue.assigned_to_id != params[:issue][:assigned_to_id].to_i + issue_id = @issue.id + issue_title = params[:issue][:subject] + priority_id = params[:issue][:priority_id] + ps = ProjectsService.new + ps.send_wechat_project_issue_notice senduser,@issue.project,issue_id,issue_title,priority_id + end end @issue.safe_attributes = issue_attributes - @priorities = IssuePriority.active @allowed_statuses = @issue.new_statuses_allowed_to(User.current) true diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index ea15af42e..0f209f920 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -1,4 +1,4 @@ -