Project

General

Profile

Actions

Patch #5891

open

New IssuesController hook for new issues

Added by Nick Peelman over 14 years ago. Updated almost 8 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
Hook requests
Target version:
-
Start date:
2010-07-16
Due date:
% Done:

0%

Estimated time:

Description

While working on my CC Addresses plugin, I have come across the need to work with @issue during its creation in order to call @issue.cc_addresses.build before render gets called.

The :controller_issues_new_before_save hook only gets called after the form has been submitted, this ties the hands of plugins trying to extend the issue form (like i'm trying to do, obviously).

Adding the hook below allows you to touch the @issue object before render, letting you build nested_attribute objects, etc.

Index: app/controllers/issues_controller.rb
===================================================================
--- app/controllers/issues_controller.rb    (revision 3840)
+++ app/controllers/issues_controller.rb    (working copy)
@@ -145,9 +145,10 @@
     end    
     @issue.status = default_status
     @allowed_statuses = ([default_status] + default_status.find_new_statuses_allowed_to(User.current.roles_for_project(@project), @issue.tracker)).uniq

     if request.get? || request.xhr?
       @issue.start_date ||= Date.today
+      call_hook(:controller_issues_new_prepare, { :params => params, :issue => @issue })
     else
       requested_status = IssueStatus.find_by_id(params[:issue][:status_id]) if params[:issue]
       # Check that the user is allowed to apply the requested status

Would be great to see this in the next release, its a relatively minor change. Thanks!

Actions

Also available in: Atom PDF