プロジェクト

全般

プロフィール

Vote #64409

完了

Hooks for IssuesController

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Plugin API_20
対象バージョン:
開始日:
2009/01/09
期日:
進捗率:

100%

予定工数:
category_id:
20
version_id:
12
issue_org_id:
2475
author_id:
3052
assigned_to_id:
5
comments:
5
status_id:
5
tracker_id:
2
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

I have been tasked with providing a plugin to allow Redmine to act as a controller for a 3rd party VCS system's built in issue tracker. In order to reduce situations where orphaned issue records could be created in the 3rd party tool, Hook events need to be called After issues have been saved in Redmine.

At present, I have modified my own Redmine installation's @issues_controller.rb@ file to provide hooks in the @new()@ and @edit()@ methods of the @IssuesController@ class, directly after the @redirect_to@ statements in those methods.

In the @add()@ method, I have done the following:

...
if @issue.save
  attach_files(@issue, params[:attachments])
  flash[:notice] = l(:notice_successful_create)
  Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('issue_added')
  redirect_to :controller => 'issues', :action => 'show', :id => @issue
  #
  call_hook(:controller_issues_new_after_save, { :issue => @issue })
  #
  return
end
...

... and in @edit()@:

  ...
  if !journal.new_record?
    # Only send notification if something was actually changed
    flash[:notice] = l(:notice_successful_update)
    Mailer.deliver_issue_edit(journal) if Setting.notified_events.include?('issue_updated')
  end
  redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
  #
  call_hook(:controller_issues_edit_after_save, { :params => params, :issue => @issue, :time_entry => @time_entry, :journal => journal})
  #
  ...

For my own most immediate requirements, this is the minimum I have needed to get the job done, and would very much appreciate if the feature could be added to future releases of Redmine, as this would save me needing to edit Redmine source whenever a new version is release.

I can however envisage situations where before and after events could be needed for issue creation, editing, deletion, or possibly anywhere that issue record changes are submitted.

Thanks.

Sean


journals

I'll add some hooks in there. I might move them a bit, I think they should run before any redirects.
--------------------------------------------------------------------------------
I've added the hooks in r2261. If you need any other hooks, go ahead and open a new issue for them and assign it to me.
--------------------------------------------------------------------------------
Eric, the revision @2261 associated with this issue (for the version 0.8.1) wasn't yet merged into 0.8-branche. I was using (:controller_issues_new_after_save, :controller_issues_edit_after_save) api hooks for issues controller using 0.8-branche and them simply did not work.

I make a svn diff to last revision of the 0.8-branche (@2900) and to revision @2261 showing that which was put in your revision wasnt find in 0.8-branche.

@@ -147,8 +147,8 @@
attach_files(@issue, params[:attachments])
flash[:notice] = l(:notice_successful_create)
Mailer.deliver_issue_add(@issue) if Setting.notified_events.include?('i
ssue_added')
- redirect_to(params[:continue] ? { :action => 'new', :tracker_id => @iss
ue.tracker } :
- { :action => 'show', :id => @issue })
+ call_hook(:controller_issues_new_after_save, { :params => params, :issu
e => @issue})
+ redirect_to :controller => 'issues', :action => 'show', :id => @issue
return
end
end

@@ -194,6 +194,7 @@
flash[:notice] = l(:notice_successful_update)
Mailer.deliver_issue_edit(journal) if Setting.notified_events.include
?('issue_updated')
end
+ call_hook(:controller_issues_edit_after_save, { :params => params, :iss
ue => @issue, :time_entry => @time_entry, :journal => journal})
redirect_to(params[:back_to] || {:action => 'show', :id => @issue})
end
end
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Merged in 0.8-stable in r2997.
--------------------------------------------------------------------------------


related_issues

relates,Closed,3118,hook controller_issues_new_after_save is missing from issues_controller

Admin Redmine さんが約4年前に更新

  • カテゴリPlugin API_20 にセット
  • 対象バージョン0.8.6_12 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0