trackers_controller.rb
101 lines
| 3.0 KiB
| text/x-ruby
|
RubyLexer
|
r2462 | # Redmine - project management software | ||
|
r9453 | # Copyright (C) 2006-2012 Jean-Philippe Lang | ||
|
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. | ||||
|
r6685 | # | ||
|
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. | ||||
|
r6685 | # | ||
|
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 TrackersController < ApplicationController | ||||
|
r3062 | layout 'admin' | ||
|
r6685 | |||
|
r7757 | before_filter :require_admin, :except => :index | ||
before_filter :require_admin_or_api_request, :only => :index | ||||
accept_api_auth :index | ||||
|
r2 | |||
|
r3323 | def index | ||
|
r7757 | respond_to do |format| | ||
format.html { | ||||
@tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position' | ||||
render :action => "index", :layout => false if request.xhr? | ||||
} | ||||
format.api { | ||||
|
r9531 | @trackers = Tracker.sorted.all | ||
|
r7757 | } | ||
end | ||||
|
r2 | end | ||
def new | ||||
|
r7768 | @tracker ||= Tracker.new(params[:tracker]) | ||
|
r10704 | @trackers = Tracker.sorted.all | ||
|
r10687 | @projects = Project.all | ||
|
r7768 | end | ||
def create | ||||
|
r2 | @tracker = Tracker.new(params[:tracker]) | ||
if request.post? and @tracker.save | ||||
|
r396 | # workflow copy | ||
|
r595 | if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from])) | ||
|
r9794 | @tracker.workflow_rules.copy(copy_from) | ||
|
r396 | end | ||
|
r15 | flash[:notice] = l(:notice_successful_create) | ||
|
r3323 | redirect_to :action => 'index' | ||
|
r2333 | return | ||
|
r2 | end | ||
|
r7768 | new | ||
render :action => 'new' | ||||
|
r2 | end | ||
def edit | ||||
|
r7768 | @tracker ||= Tracker.find(params[:id]) | ||
|
r10687 | @projects = Project.all | ||
|
r7768 | end | ||
|
r10624 | |||
|
r7768 | def update | ||
|
r2 | @tracker = Tracker.find(params[:id]) | ||
|
r7768 | if request.put? and @tracker.update_attributes(params[:tracker]) | ||
|
r15 | flash[:notice] = l(:notice_successful_update) | ||
|
r3323 | redirect_to :action => 'index' | ||
|
r2333 | return | ||
|
r2 | end | ||
|
r7768 | edit | ||
render :action => 'edit' | ||||
|
r2 | end | ||
|
r6685 | |||
|
r2 | def destroy | ||
|
r330 | @tracker = Tracker.find(params[:id]) | ||
unless @tracker.issues.empty? | ||||
|
r3513 | flash[:error] = l(:error_can_not_delete_tracker) | ||
|
r330 | else | ||
@tracker.destroy | ||||
|
r2 | end | ||
|
r3323 | redirect_to :action => 'index' | ||
|
r6685 | end | ||
|
r10100 | |||
def fields | ||||
if request.post? && params[:trackers] | ||||
params[:trackers].each do |tracker_id, tracker_params| | ||||
tracker = Tracker.find_by_id(tracker_id) | ||||
if tracker | ||||
tracker.core_fields = tracker_params[:core_fields] | ||||
tracker.custom_field_ids = tracker_params[:custom_field_ids] | ||||
tracker.save | ||||
end | ||||
end | ||||
flash[:notice] = l(:notice_successful_update) | ||||
redirect_to :action => 'fields' | ||||
return | ||||
end | ||||
@trackers = Tracker.sorted.all | ||||
@custom_fields = IssueCustomField.all.sort | ||||
end | ||||
|
r2 | end | ||