##// END OF EJS Templates
When copying issues, let the status be changed to default or left unchanged....
When copying issues, let the status be changed to default or left unchanged. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9404 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r9270:09375960d69d
r9270:09375960d69d
Show More
issues_controller.rb
439 lines | 15.8 KiB | text/x-ruby | RubyLexer
/ app / controllers / issues_controller.rb
Jean-Philippe Lang
Adds support for free ticket filtering and custom queries on Calendar....
r1796 # Redmine - project management software
Jean-Philippe Lang
Adds an issues visibility level on roles (#7412)....
r5296 # Copyright (C) 2006-2011 Jean-Philippe Lang
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703 #
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class IssuesController < ApplicationController
Jean-Philippe Lang
Fixes selected menu tab when issue creation fails....
r3590 menu_item :new_issue, :only => [:new, :create]
Jean-Philippe Lang
Contextual quick search (#3263)....
r2829 default_search_scope :issues
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Eric Davis
Refactor: move IssuesController#reply to JournalsController...
r3827 before_filter :find_issue, :only => [:show, :edit, :update]
Jean-Philippe Lang
Removed dead code....
r8831 before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy]
Eric Davis
Refactor: merge IssuesController#update_form into IssuesController#new...
r3897 before_filter :find_project, :only => [:new, :create]
Eric Davis
Refactor: move IssuesController#changes to JournalsController#index....
r3920 before_filter :authorize, :except => [:index]
before_filter :find_optional_project, :only => [:index]
Eric Davis
Refactor: extract error to new method with before_filter....
r3576 before_filter :check_for_default_issue_status, :only => [:new, :create]
Eric Davis
Refactor: Extract duplicated code to a new method....
r3575 before_filter :build_new_issue_from_params, :only => [:new, :create]
Jean-Philippe Lang
Separation of RSS/API auth actions....
r6077 accept_rss_auth :index, :show
accept_api_auth :index, :show, :create, :update, :destroy
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330
Jean-Philippe Lang
Rescue invalid query statement error with an error message....
r2990 rescue_from Query::StatementInvalid, :with => :query_statement_invalid
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
Administrators can edit issue notes....
r1091 helper :journals
Jean-Philippe Lang
Fixed version field on issue view page now links to the corresponding version in the roadmap....
r559 helper :projects
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703 include ProjectsHelper
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 helper :custom_fields
include CustomFieldsHelper
Jean-Philippe Lang
Issue relations first commit (not thoroughly tested). 4 kinds of relation are available:...
r503 helper :issue_relations
include IssueRelationsHelper
Jean-Philippe Lang
Added watchers for message boards (watchers controller modified to support any watchable model)....
r527 helper :watchers
include WatchersHelper
Jean-Philippe Lang
Attachments can now be added to wiki pages (original patch by Pavol Murin). Only authorized users can add/delete attachments....
r538 helper :attachments
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673 include AttachmentsHelper
helper :queries
Jean-Philippe Lang
Fixed: PDF export of a issue list grouped by a custom field raises an error (#4600)....
r3219 include QueriesHelper
Toshi MARUYAMA
Fix associated revisions label on issue page....
r4532 helper :repositories
include RepositoriesHelper
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673 helper :sort
include SortHelper
Jean-Philippe Lang
ProjectsController#list_issues, #export_issues_csv and #export_issues_pdf merged into IssuesController#index...
r874 include IssuesHelper
Jean-Philippe Lang
Addq "please select" to activity select box if no activity is set as default (#937)....
r1588 helper :timelog
Eric Davis
Rewrite the Gantt chart. #6276...
r3958 helper :gantt
Jean-Philippe Lang
Move PDF stuff to a single helper....
r2224 include Redmine::Export::PDF
Jean-Philippe Lang
data locking for issues...
r21
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673 def index
retrieve_query
Jean-Philippe Lang
Ability to save "sort order" in custom queries (#2899)....
r2504 sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
Eric Davis
Refactor: Extract Query#sortable_columns from the controller....
r3490 sort_update(@query.sortable_columns)
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673 if @query.valid?
Jean-Philippe Lang
Restores object count and adds offset/limit attributes to API responses for paginated collections (#6140)....
r4375 case params[:format]
Jean-Philippe Lang
Fixed: invalid format parameter returns a DoubleRenderError on issues index (#4737)....
r3254 when 'csv', 'pdf'
Jean-Philippe Lang
Restores object count and adds offset/limit attributes to API responses for paginated collections (#6140)....
r4375 @limit = Setting.issues_export_limit.to_i
Jean-Philippe Lang
Fixed: invalid format parameter returns a DoubleRenderError on issues index (#4737)....
r3254 when 'atom'
Jean-Philippe Lang
Restores object count and adds offset/limit attributes to API responses for paginated collections (#6140)....
r4375 @limit = Setting.feeds_limit.to_i
when 'xml', 'json'
@offset, @limit = api_offset_and_limit
Jean-Philippe Lang
Fixed: invalid format parameter returns a DoubleRenderError on issues index (#4737)....
r3254 else
Jean-Philippe Lang
Restores object count and adds offset/limit attributes to API responses for paginated collections (#6140)....
r4375 @limit = per_page_option
Jean-Philippe Lang
Display links to Atom feeds (closes #496, #750)....
r1171 end
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
Move issues, journals, versions queries from IssuesController to Query model....
r2989 @issue_count = @query.issue_count
Jean-Philippe Lang
Restores object count and adds offset/limit attributes to API responses for paginated collections (#6140)....
r4375 @issue_pages = Paginator.new self, @issue_count, @limit, params['page']
@offset ||= @issue_pages.current.offset
Jean-Philippe Lang
Move issues, journals, versions queries from IssuesController to Query model....
r2989 @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version],
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703 :order => sort_clause,
:offset => @offset,
Jean-Philippe Lang
Restores object count and adds offset/limit attributes to API responses for paginated collections (#6140)....
r4375 :limit => @limit)
Jean-Philippe Lang
Move issues, journals, versions queries from IssuesController to Query model....
r2989 @issue_count_by_group = @query.issue_count_by_group
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
ProjectsController#list_issues, #export_issues_csv and #export_issues_pdf merged into IssuesController#index...
r874 respond_to do |format|
Toshi MARUYAMA
remove hard-coded '.rhtml' from IssuesController 'index' (#6317)....
r6902 format.html { render :template => 'issues/index', :layout => !request.xhr? }
Toshi MARUYAMA
remove trailing white-spaces from app/controllers/issues_controller.rb....
r6764 format.api {
Jean-Philippe Lang
Ability to load relations on /issues API (#7366)....
r6193 Issue.load_relations(@issues) if include_in_api_response?('relations')
}
Jean-Philippe Lang
Adds project name to issues feed title (#1323)....
r1627 format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
Jean-Philippe Lang
Adds a dialog box for CSV export options (#4742)....
r7754 format.csv { send_data(issues_to_csv(@issues, @project, @query, params), :type => 'text/csv; header=present', :filename => 'export.csv') }
Jean-Philippe Lang
Ticket grouping (#2679)....
r2604 format.pdf { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
Jean-Philippe Lang
ProjectsController#list_issues, #export_issues_csv and #export_issues_pdf merged into IssuesController#index...
r874 end
else
Jean-Philippe Lang
Respond with errors and appropriate content type on /issues API calls with invalid query params (#8883)....
r6189 respond_to do |format|
Toshi MARUYAMA
respond nothing in case of content type is not html with invalid query params (#8883, #6317)....
r6904 format.html { render(:template => 'issues/index', :layout => !request.xhr?) }
format.any(:atom, :csv, :pdf) { render(:nothing => true) }
Jean-Philippe Lang
Respond with errors and appropriate content type on /issues API calls with invalid query params (#8883)....
r6189 format.api { render_validation_errors(@query) }
end
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673 end
Jean-Philippe Lang
Queries can be marked as 'For all projects'. Such queries will be available on all projects and on the global issue list (#897, closes #671)....
r1296 rescue ActiveRecord::RecordNotFound
render_404
Jean-Philippe Lang
ProjectsController#list_issues, #export_issues_csv and #export_issues_pdf merged into IssuesController#index...
r874 end
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
data locking for issues...
r21 def show
Jean-Philippe Lang
Issue history is now 'oldest first' sorted....
r627 @journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC")
Jean-Philippe Lang
Add a user preference to choose how comments/replies are displayed: in chronological or reverse chronological order (#589, #776)....
r1183 @journals.each_with_index {|j,i| j.indice = i+1}
Jean-Philippe Lang
Fixed no method error due to typo....
r5326 @journals.reverse! if User.current.wants_comments_in_reverse_order?
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
Fixed: associated changesets from other projects are not visible if the current project doesn't have the repository module enabled (#3087)....
r8629 @changesets = @issue.changesets.visible.all
@changesets.reverse! if User.current.wants_comments_in_reverse_order?
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
Moves relations fetching from views to the controller and skip invalid relations (#7385)....
r4621 @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
Jean-Philippe Lang
Merged IssuesController #edit and #update into a single actions....
r1115 @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
Jean-Baptiste Barth
Do not show inactive issue priorities where not necessary (#8573)....
r5950 @priorities = IssuePriority.active
Jean-Philippe Lang
Initialize TimeEntry with issue and project for the issue edit form....
r5154 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
Jean-Philippe Lang
ProjectsController#list_issues, #export_issues_csv and #export_issues_pdf merged into IssuesController#index...
r874 respond_to do |format|
Jean-Philippe Lang
Adds previous/next links to issue (#2850)....
r8368 format.html {
retrieve_previous_and_next_issue_ids
render :template => 'issues/show'
}
Jean-Philippe Lang
Adds a pseudo format to api template names and overrides ActionController#default_template so that api templates are chosen automatically....
r4352 format.api
Eric Davis
Refactor: move IssuesController#changes to JournalsController#index....
r3920 format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
Jean-Philippe Lang
Move PDF stuff to a single helper....
r2224 format.pdf { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
Jean-Philippe Lang
Merged IssuesController#export_pdf into IssuesController#show....
r799 end
Jean-Philippe Lang
data locking for issues...
r21 end
Jean-Philippe Lang
Initial commit...
r2
Jean-Philippe Lang
ProjectsController#add_issue moved to IssuesController#new....
r1066 # Add a new issue
# The new issue will be created from an existing one if copy_from parameter is given
def new
Eric Davis
Refactor: merge IssuesController#update_form into IssuesController#new...
r3897 respond_to do |format|
format.html { render :action => 'new', :layout => !request.xhr? }
Jean-Philippe Lang
Allows project to be changed from the regular issue update action (#4769, #9803)....
r8411 format.js {
render(:update) { |page|
if params[:project_change]
page.replace_html 'all_attributes', :partial => 'form'
else
page.replace_html 'attributes', :partial => 'attributes'
end
m = User.current.allowed_to?(:log_time, @issue.project) ? 'show' : 'hide'
page << "if ($('log_time')) {Element.#{m}('log_time');}"
}
}
Eric Davis
Refactor: merge IssuesController#update_form into IssuesController#new...
r3897 end
Eric Davis
Refactor: Split IssuesController#new to #new and #create to match REST pattern....
r3574 end
def create
call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
Jean-Philippe Lang
Adds support for adding attachments to issues through the REST API (#8171)....
r8808 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
Eric Davis
Refactor: Split IssuesController#new to #new and #create to match REST pattern....
r3574 if @issue.save
call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
respond_to do |format|
format.html {
Jean-Philippe Lang
Adds issue id link in the issue creation flash message (#3033)....
r6090 render_attachment_warning_if_needed(@issue)
flash[:notice] = l(:notice_issue_successful_create, :id => "<a href='#{issue_path(@issue)}'>##{@issue.id}</a>")
Jean-Philippe Lang
Use the regular issue form to copy a single issue....
r8432 redirect_to(params[:continue] ? { :action => 'new', :project_id => @issue.project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
Eric Davis
Refactor: Split IssuesController#new to #new and #create to match REST pattern....
r3574 { :action => 'show', :id => @issue })
}
Jean-Philippe Lang
Adds a pseudo format to api template names and overrides ActionController#default_template so that api templates are chosen automatically....
r4352 format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
Eric Davis
Refactor: Split IssuesController#new to #new and #create to match REST pattern....
r3574 end
return
else
respond_to do |format|
format.html { render :action => 'new' }
Jean-Philippe Lang
Converts IssuesController to use the new API template system and makes xml/json responses consistent (#6136)....
r4344 format.api { render_validation_errors(@issue) }
Eric Davis
Refactor: Split IssuesController#new to #new and #create to match REST pattern....
r3574 end
end
Jean-Philippe Lang
ProjectsController#add_issue moved to IssuesController#new....
r1066 end
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 def edit
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 return unless update_issue_from_params
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116
Eric Davis
Refactor: Move the updating of an Issue to the #update method....
r3372 respond_to do |format|
format.html { }
format.xml { }
end
end
def update
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 return unless update_issue_from_params
Jean-Philippe Lang
Adds support for adding attachments to issues through the REST API (#8171)....
r8808 @issue.save_attachments(params[:attachments] || (params[:issue] && params[:issue][:uploads]))
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 saved = false
begin
saved = @issue.save_issue_with_child_records(params, @time_entry)
rescue ActiveRecord::StaleObjectError
@conflict = true
if params[:last_journal_id]
if params[:last_journal_id].present?
last_journal_id = params[:last_journal_id].to_i
@conflict_journals = @issue.journals.all(:conditions => ["#{Journal.table_name}.id > ?", last_journal_id])
else
@conflict_journals = @issue.journals.all
end
end
end
Eric Davis
Refactor: Move the updating of an Issue to the #update method....
r3372
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 if saved
Eric Davis
Refactor: Moved the contents of #issue_update into Issue....
r3431 render_attachment_warning_if_needed(@issue)
Eric Davis
Remove double negative condition...
r3432 flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
Eric Davis
Refactor: Moved the contents of #issue_update into Issue....
r3431
Eric Davis
Refactor: Extracted saving logic out of #update and into a utility method...
r3383 respond_to do |format|
format.html { redirect_back_or_default({:action => 'show', :id => @issue}) }
Jean-Philippe Lang
Converts IssuesController to use the new API template system and makes xml/json responses consistent (#6136)....
r4344 format.api { head :ok }
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
Eric Davis
Refactor: Extracted saving logic out of #update and into a utility method...
r3383 else
Jean-Philippe Lang
XML REST API for issues that provides CRUD operations for Issues (#1214)....
r3196 respond_to do |format|
Eric Davis
Refactor: Start to extract IssuesController#edit into #update (REST)....
r3366 format.html { render :action => 'edit' }
Jean-Philippe Lang
Converts IssuesController to use the new API template system and makes xml/json responses consistent (#6136)....
r4344 format.api { render_validation_errors(@issue) }
Jean-Philippe Lang
XML REST API for issues that provides CRUD operations for Issues (#1214)....
r3196 end
Jean-Philippe Lang
Merged IssuesController change_status and add_note actions....
r1030 end
Jean-Philippe Lang
data locking for issues...
r21 end
Jean-Philippe Lang
Copy issues via bulk update action....
r8418 # Bulk edit/copy a set of issues
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 def bulk_edit
Jean-Philippe Lang
Adds subtasking (#443) including:...
r3459 @issues.sort!
Jean-Philippe Lang
Copy issues via bulk update action....
r8418 @copy = params[:copy].present?
@notes = params[:notes]
Jean-Philippe Lang
Allows project to be changed from the bulk edit form....
r8416
if User.current.allowed_to?(:move_issues, @projects)
@allowed_projects = Issue.allowed_target_projects_on_move
if params[:issue]
Jean-Philippe Lang
Fixed that the bulk edit/copy form does not propose versions and categories for the target project (#10350)....
r8926 @target_project = @allowed_projects.detect {|p| p.id.to_s == params[:issue][:project_id].to_s}
Jean-Philippe Lang
Allows project to be changed from the bulk edit form....
r8416 if @target_project
target_projects = [@target_project]
end
end
end
target_projects ||= @projects
Jean-Philippe Lang
When copying issues, let the status be changed to default or left unchanged....
r9270 if @copy
@available_statuses = [IssueStatus.default]
else
@available_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
end
Jean-Philippe Lang
Use #reduce instead of #inject for getting the intersection of arrays....
r8707 @custom_fields = target_projects.map{|p|p.all_issue_custom_fields}.reduce(:&)
@assignables = target_projects.map(&:assignable_users).reduce(:&)
@trackers = target_projects.map(&:trackers).reduce(:&)
Jean-Philippe Lang
Fixed that the bulk edit/copy form does not propose versions and categories for the target project (#10350)....
r8926 @versions = target_projects.map {|p| p.shared_versions.open}.reduce(:&)
@categories = target_projects.map {|p| p.issue_categories}.reduce(:&)
Jean-Philippe Lang
Allows project to be changed from the bulk edit form....
r8416
Jean-Philippe Lang
Use #reduce instead of #inject for getting the intersection of arrays....
r8707 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
Jean-Philippe Lang
Allows project to be changed from the bulk edit form....
r8416 render :layout => false if request.xhr?
Jean-Philippe Lang
Issue list now supports bulk edit/move/delete (#563, #607). For now, issues from different projects can not be bulk edited/moved/deleted at once....
r1116 end
Eric Davis
Refactor: extract #bulk_update method from IssuesController#bulk_edit....
r3923
def bulk_update
@issues.sort!
Jean-Philippe Lang
Copy issues via bulk update action....
r8418 @copy = params[:copy].present?
Eric Davis
Refactor: extract method in bulk_update....
r3926 attributes = parse_params_for_bulk_issue_attributes(params)
Eric Davis
Refactor: extract #bulk_update method from IssuesController#bulk_edit....
r3923
unsaved_issue_ids = []
Jean-Philippe Lang
Allows project to be changed from the bulk edit form....
r8416 moved_issues = []
Eric Davis
Refactor: extract #bulk_update method from IssuesController#bulk_edit....
r3923 @issues.each do |issue|
issue.reload
Jean-Philippe Lang
Copy issues via bulk update action....
r8418 if @copy
Jean-Philippe Lang
Deprecated Issue#move_to_project....
r8419 issue = issue.copy
Jean-Philippe Lang
Copy issues via bulk update action....
r8418 end
Eric Davis
Refactor: extract #bulk_update method from IssuesController#bulk_edit....
r3923 journal = issue.init_journal(User.current, params[:notes])
issue.safe_attributes = attributes
call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue })
Jean-Philippe Lang
Allows project to be changed from the bulk edit form....
r8416 if issue.save
moved_issues << issue
else
Eric Davis
Refactor: extract #bulk_update method from IssuesController#bulk_edit....
r3923 # Keep unsaved issue ids to display them in flash error
unsaved_issue_ids << issue.id
end
end
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids)
Jean-Philippe Lang
Allows project to be changed from the bulk edit form....
r8416
if params[:follow]
if @issues.size == 1 && moved_issues.size == 1
redirect_to :controller => 'issues', :action => 'show', :id => moved_issues.first
elsif moved_issues.map(&:project).uniq.size == 1
redirect_to :controller => 'issues', :action => 'index', :project_id => moved_issues.map(&:project).first
end
else
redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project})
end
Eric Davis
Refactor: extract #bulk_update method from IssuesController#bulk_edit....
r3923 end
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
data locking for issues...
r21 def destroy
Jean-Philippe Lang
Let the user choose when deleting issues with reported hours (closes #734, #71):...
r1168 @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
if @hours > 0
case params[:todo]
when 'destroy'
# nothing to do
when 'nullify'
TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues])
when 'reassign'
reassign_to = @project.issues.find_by_id(params[:reassign_to_id])
if reassign_to.nil?
flash.now[:error] = l(:error_issue_not_found_in_project)
return
else
TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues])
end
else
Jean-Philippe Lang
Converts IssuesController to use the new API template system and makes xml/json responses consistent (#6136)....
r4344 # display the destroy form if it's a user request
return unless api_request?
Jean-Philippe Lang
Let the user choose when deleting issues with reported hours (closes #734, #71):...
r1168 end
end
Jean-Philippe Lang
Fixed: bulk destroying parent and child issues raises a stale object error (#7920)....
r5163 @issues.each do |issue|
begin
issue.reload.destroy
rescue ::ActiveRecord::RecordNotFound # raised by #reload if issue no longer exists
# nothing to do, issue was already deleted (eg. by a parent)
end
end
Jean-Philippe Lang
XML REST API for issues that provides CRUD operations for Issues (#1214)....
r3196 respond_to do |format|
Jean-Baptiste Barth
Added ability to delete issues from different projects through contextual menu (#5332)...
r4122 format.html { redirect_back_or_default(:action => 'index', :project_id => @project) }
Jean-Philippe Lang
Converts IssuesController to use the new API template system and makes xml/json responses consistent (#6136)....
r4344 format.api { head :ok }
Jean-Philippe Lang
XML REST API for issues that provides CRUD operations for Issues (#1214)....
r3196 end
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 end
private
Jean-Philippe Lang
ProjectsController#add_issue moved to IssuesController#new....
r1066 def find_issue
Jean-Philippe Lang
Adds an issues visibility level on roles (#7412)....
r5296 # Issue.visible.find(...) can not be used to redirect user to the login form
# if the issue actually exists but requires authentication
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 @issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
Jean-Philippe Lang
Adds an issues visibility level on roles (#7412)....
r5296 unless @issue.visible?
deny_access
return
end
Jean-Philippe Lang
added svn:eol-style native property on /app files...
r330 @project = @issue.project
rescue ActiveRecord::RecordNotFound
render_404
Jean-Philippe Lang
Added a cross-project issue list. It displays the issues of all the projects visible by the user....
r673 end
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
ProjectsController#add_issue moved to IssuesController#new....
r1066 def find_project
Jean-Philippe Lang
Allows project to be changed from the regular issue update action (#4769, #9803)....
r8411 project_id = params[:project_id] || (params[:issue] && params[:issue][:project_id])
Jean-Philippe Lang
XML REST API for issues that provides CRUD operations for Issues (#1214)....
r3196 @project = Project.find(project_id)
Jean-Philippe Lang
ProjectsController#add_issue moved to IssuesController#new....
r1066 rescue ActiveRecord::RecordNotFound
render_404
end
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Jean-Philippe Lang
Adds previous/next links to issue (#2850)....
r8368 def retrieve_previous_and_next_issue_ids
retrieve_query_from_session
if @query
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria)
sort_update(@query.sortable_columns, 'issues_index_sort')
limit = 500
Jean-Philippe Lang
Fixed: error when displaying an issue with a query sorted by an association, eg. priority (#9936)....
r8449 issue_ids = @query.issue_ids(:order => sort_clause, :limit => (limit + 1), :include => [:assigned_to, :tracker, :priority, :category, :fixed_version])
Jean-Philippe Lang
Makes .find_ids return integers....
r8370 if (idx = issue_ids.index(@issue.id)) && idx < limit
Jean-Philippe Lang
Display the position of the current issue in the query results....
r8543 if issue_ids.size < 500
@issue_position = idx + 1
@issue_count = issue_ids.size
end
Jean-Philippe Lang
Makes .find_ids return integers....
r8370 @prev_issue_id = issue_ids[idx - 1] if idx > 0
@next_issue_id = issue_ids[idx + 1] if idx < (issue_ids.size - 1)
Jean-Philippe Lang
Adds previous/next links to issue (#2850)....
r8368 end
end
end
Eric Davis
Refactor: Extracted the duplication from the last commit into a new method...
r3373 # Used by #edit and #update to set some common instance variables
# from the params
# TODO: Refactor, not everything in here is needed by #edit
def update_issue_from_params
@edit_allowed = User.current.allowed_to?(:edit_issues, @project)
Jean-Philippe Lang
Initialize TimeEntry with issue and project for the issue edit form....
r5154 @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
Jean-Philippe Lang
Initialize TimeEntry attributes with params when editing an issue (#5441)....
r4297 @time_entry.attributes = params[:time_entry]
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Eric Davis
Allow setting an issue's notes via params[:issue][:notes]. (XML API)...
r3934 @notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
Eric Davis
Refactor: Replace @journal with @issue.current_journal...
r3426 @issue.init_journal(User.current, @notes)
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654
issue_attributes = params[:issue]
if issue_attributes && params[:conflict_resolution]
case params[:conflict_resolution]
when 'overwrite'
issue_attributes = issue_attributes.dup
issue_attributes.delete(:lock_version)
when 'add_notes'
issue_attributes = {}
when 'cancel'
redirect_to issue_path(@issue)
return false
end
end
@issue.safe_attributes = issue_attributes
Jean-Philippe Lang
Fixed that improper statuses are proposed when changing status before tracker on the issue form (#10619)....
r9244 @priorities = IssuePriority.active
@allowed_statuses = @issue.new_statuses_allowed_to(User.current)
Jean-Philippe Lang
Better handling of issue update conflicts (#8691)....
r8654 true
Eric Davis
Refactor: Extracted the duplication from the last commit into a new method...
r3373 end
Eric Davis
Refactor: Extract method for setting the flash on bulk issue saves....
r3446
Eric Davis
Refactor: Extract duplicated code to a new method....
r3575 # TODO: Refactor, lots of extra code in here
Jean-Baptiste Barth
Fixed: don't reset watchers when changing tracker. #6479...
r4067 # TODO: Changing tracker on an existing issue should not trigger this
Eric Davis
Refactor: Extract duplicated code to a new method....
r3575 def build_new_issue_from_params
Eric Davis
Refactor: merge IssuesController#update_form into IssuesController#new...
r3897 if params[:id].blank?
@issue = Issue.new
Jean-Philippe Lang
Adds an option of the copy form to enable/disable attachments copy (#3055)....
r8557 if params[:copy_from]
begin
@copy_from = Issue.visible.find(params[:copy_from])
@copy_attachments = params[:copy_attachments].present? || request.get?
@issue.copy_from(@copy_from, :attachments => @copy_attachments)
rescue ActiveRecord::RecordNotFound
render_404
return
end
Jean-Philippe Lang
Fixed an error when trying to copy an issue that does not exist....
r8550 end
Eric Davis
Refactor: merge IssuesController#update_form into IssuesController#new...
r3897 @issue.project = @project
else
@issue = @project.issues.visible.find(params[:id])
end
Toshi MARUYAMA
remove trailing white-spaces from issues controller source....
r5703
Eric Davis
Refactor: Extract duplicated code to a new method....
r3575 @issue.project = @project
Jean-Philippe Lang
Fixed: Private flag ignored when creating an issue with set_own_issues_private permission only (#8472)....
r5871 @issue.author = User.current
Eric Davis
Refactor: Extract duplicated code to a new method....
r3575 # Tracker must be set before custom field values
@issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first)
if @issue.tracker.nil?
render_error l(:error_no_tracker_in_project)
return false
end
Etienne Massip
Added an administration setting to allow issue start date to be defaulted to blank (nil) at issue creation (#2269)....
r7613 @issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
Jean-Philippe Lang
Use safe_attributes for issue watchers assignment....
r8077 @issue.safe_attributes = params[:issue]
Jean-Baptiste Barth
Do not show inactive issue priorities where not necessary (#8573)....
r5950 @priorities = IssuePriority.active
Eric Davis
Refactor: Extract duplicated code to a new method....
r3575 @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
Jean-Philippe Lang
Ability to add non-member watchers on issue creation (#5159)....
r9134 @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq
Eric Davis
Refactor: Extract duplicated code to a new method....
r3575 end
Eric Davis
Refactor: extract error to new method with before_filter....
r3576 def check_for_default_issue_status
if IssueStatus.default.nil?
render_error l(:error_no_default_issue_status)
return false
end
end
Eric Davis
Refactor: extract method in bulk_update....
r3926
def parse_params_for_bulk_issue_attributes(params)
attributes = (params[:issue] || {}).reject {|k,v| v.blank?}
attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'}
Jean-Philippe Lang
Let non required list/user/version custom fields to be set to blank when bulk editing (#10605)....
r9215 if custom = attributes[:custom_field_values]
custom.reject! {|k,v| v.blank?}
custom.keys.each do |k|
if custom[k].is_a?(Array)
custom[k] << '' if custom[k].delete('__none__')
else
custom[k] = '' if custom[k] == '__none__'
end
end
end
Eric Davis
Refactor: extract method in bulk_update....
r3926 attributes
end
Jean-Philippe Lang
Initial commit...
r2 end