|
|
@@ -5,12 +5,12 @@ |
|
|
|
# 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. |
|
|
|
# |
|
|
|
# |
|
|
|
# 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. |
|
|
|
# |
|
|
|
# |
|
|
|
# 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. |
|
|
@@ -18,7 +18,7 @@ |
|
|
|
class IssuesController < ApplicationController |
|
|
|
menu_item :new_issue, :only => [:new, :create] |
|
|
|
default_search_scope :issues |
|
|
|
|
|
|
|
|
|
|
|
before_filter :find_issue, :only => [:show, :edit, :update] |
|
|
|
before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :move, :perform_move, :destroy] |
|
|
|
before_filter :check_project_uniqueness, :only => [:move, :perform_move] |
|
|
@@ -30,10 +30,10 @@ class IssuesController < ApplicationController |
|
|
|
accept_key_auth :index, :show, :create, :update, :destroy |
|
|
|
|
|
|
|
rescue_from Query::StatementInvalid, :with => :query_statement_invalid |
|
|
|
|
|
|
|
|
|
|
|
helper :journals |
|
|
|
helper :projects |
|
|
|
include ProjectsHelper |
|
|
|
include ProjectsHelper |
|
|
|
helper :custom_fields |
|
|
|
include CustomFieldsHelper |
|
|
|
helper :issue_relations |
|
|
@@ -60,12 +60,12 @@ class IssuesController < ApplicationController |
|
|
|
verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed } |
|
|
|
verify :method => :post, :only => :bulk_update, :render => {:nothing => true, :status => :method_not_allowed } |
|
|
|
verify :method => :put, :only => :update, :render => {:nothing => true, :status => :method_not_allowed } |
|
|
|
|
|
|
|
|
|
|
|
def index |
|
|
|
retrieve_query |
|
|
|
sort_init(@query.sort_criteria.empty? ? [['id', 'desc']] : @query.sort_criteria) |
|
|
|
sort_update(@query.sortable_columns) |
|
|
|
|
|
|
|
|
|
|
|
if @query.valid? |
|
|
|
case params[:format] |
|
|
|
when 'csv', 'pdf' |
|
|
@@ -77,16 +77,16 @@ class IssuesController < ApplicationController |
|
|
|
else |
|
|
|
@limit = per_page_option |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@issue_count = @query.issue_count |
|
|
|
@issue_pages = Paginator.new self, @issue_count, @limit, params['page'] |
|
|
|
@offset ||= @issue_pages.current.offset |
|
|
|
@issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], |
|
|
|
:order => sort_clause, |
|
|
|
:offset => @offset, |
|
|
|
:order => sort_clause, |
|
|
|
:offset => @offset, |
|
|
|
:limit => @limit) |
|
|
|
@issue_count_by_group = @query.issue_count_by_group |
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format| |
|
|
|
format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? } |
|
|
|
format.api |
|
|
@@ -101,17 +101,17 @@ class IssuesController < ApplicationController |
|
|
|
rescue ActiveRecord::RecordNotFound |
|
|
|
render_404 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def show |
|
|
|
@journals = @issue.journals.find(:all, :include => [:user, :details], :order => "#{Journal.table_name}.created_on ASC") |
|
|
|
@journals.each_with_index {|j,i| j.indice = i+1} |
|
|
|
@journals.reverse! if User.current.wants_comments_in_reverse_order? |
|
|
|
|
|
|
|
|
|
|
|
if User.current.allowed_to?(:view_changesets, @project) |
|
|
|
@changesets = @issue.changesets.visible.all |
|
|
|
@changesets.reverse! if User.current.wants_comments_in_reverse_order? |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? } |
|
|
|
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
|
|
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
|
|
@@ -156,7 +156,7 @@ class IssuesController < ApplicationController |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def edit |
|
|
|
update_issue_from_params |
|
|
|
|
|
|
@@ -218,7 +218,7 @@ class IssuesController < ApplicationController |
|
|
|
set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids) |
|
|
|
redirect_back_or_default({:controller => 'issues', :action => 'index', :project_id => @project}) |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def destroy |
|
|
|
@hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f |
|
|
|
if @hours > 0 |
|
|
@@ -266,14 +266,14 @@ private |
|
|
|
rescue ActiveRecord::RecordNotFound |
|
|
|
render_404 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def find_project |
|
|
|
project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id] |
|
|
|
@project = Project.find(project_id) |
|
|
|
rescue ActiveRecord::RecordNotFound |
|
|
|
render_404 |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# Used by #edit and #update to set some common instance variables |
|
|
|
# from the params |
|
|
|
# TODO: Refactor, not everything in here is needed by #edit |
|
|
@@ -283,7 +283,7 @@ private |
|
|
|
@edit_allowed = User.current.allowed_to?(:edit_issues, @project) |
|
|
|
@time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project) |
|
|
|
@time_entry.attributes = params[:time_entry] |
|
|
|
|
|
|
|
|
|
|
|
@notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil) |
|
|
|
@issue.init_journal(User.current, @notes) |
|
|
|
@issue.safe_attributes = params[:issue] |
|
|
@@ -299,7 +299,7 @@ private |
|
|
|
else |
|
|
|
@issue = @project.issues.visible.find(params[:id]) |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@issue.project = @project |
|
|
|
# Tracker must be set before custom field values |
|
|
|
@issue.tracker ||= @project.trackers.find((params[:issue] && params[:issue][:tracker_id]) || params[:tracker_id] || :first) |