Revision 1297:0a574315af3e .svn/pristine/10
| .svn/pristine/10/105399d73cdd64dbe994d874bdf78e986ecd631d.svn-base | ||
|---|---|---|
| 1 |
# Redmine - project management software |
|
| 2 |
# Copyright (C) 2006-2012 Jean-Philippe Lang |
|
| 3 |
# |
|
| 4 |
# This program is free software; you can redistribute it and/or |
|
| 5 |
# modify it under the terms of the GNU General Public License |
|
| 6 |
# as published by the Free Software Foundation; either version 2 |
|
| 7 |
# of the License, or (at your option) any later version. |
|
| 8 |
# |
|
| 9 |
# This program is distributed in the hope that it will be useful, |
|
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 12 |
# GNU General Public License for more details. |
|
| 13 |
# |
|
| 14 |
# You should have received a copy of the GNU General Public License |
|
| 15 |
# along with this program; if not, write to the Free Software |
|
| 16 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
| 17 |
|
|
| 18 |
class TrackersController < ApplicationController |
|
| 19 |
layout 'admin' |
|
| 20 |
|
|
| 21 |
before_filter :require_admin, :except => :index |
|
| 22 |
before_filter :require_admin_or_api_request, :only => :index |
|
| 23 |
accept_api_auth :index |
|
| 24 |
|
|
| 25 |
def index |
|
| 26 |
respond_to do |format| |
|
| 27 |
format.html {
|
|
| 28 |
@tracker_pages, @trackers = paginate :trackers, :per_page => 10, :order => 'position' |
|
| 29 |
render :action => "index", :layout => false if request.xhr? |
|
| 30 |
} |
|
| 31 |
format.api {
|
|
| 32 |
@trackers = Tracker.sorted.all |
|
| 33 |
} |
|
| 34 |
end |
|
| 35 |
end |
|
| 36 |
|
|
| 37 |
def new |
|
| 38 |
@tracker ||= Tracker.new(params[:tracker]) |
|
| 39 |
@trackers = Tracker.find :all, :order => 'position' |
|
| 40 |
@projects = Project.find(:all) |
|
| 41 |
end |
|
| 42 |
|
|
| 43 |
def create |
|
| 44 |
@tracker = Tracker.new(params[:tracker]) |
|
| 45 |
if request.post? and @tracker.save |
|
| 46 |
# workflow copy |
|
| 47 |
if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from])) |
|
| 48 |
@tracker.workflow_rules.copy(copy_from) |
|
| 49 |
end |
|
| 50 |
flash[:notice] = l(:notice_successful_create) |
|
| 51 |
redirect_to :action => 'index' |
|
| 52 |
return |
|
| 53 |
end |
|
| 54 |
new |
|
| 55 |
render :action => 'new' |
|
| 56 |
end |
|
| 57 |
|
|
| 58 |
def edit |
|
| 59 |
@tracker ||= Tracker.find(params[:id]) |
|
| 60 |
@projects = Project.find(:all) |
|
| 61 |
end |
|
| 62 |
|
|
| 63 |
def update |
|
| 64 |
@tracker = Tracker.find(params[:id]) |
|
| 65 |
if request.put? and @tracker.update_attributes(params[:tracker]) |
|
| 66 |
flash[:notice] = l(:notice_successful_update) |
|
| 67 |
redirect_to :action => 'index' |
|
| 68 |
return |
|
| 69 |
end |
|
| 70 |
edit |
|
| 71 |
render :action => 'edit' |
|
| 72 |
end |
|
| 73 |
|
|
| 74 |
def destroy |
|
| 75 |
@tracker = Tracker.find(params[:id]) |
|
| 76 |
unless @tracker.issues.empty? |
|
| 77 |
flash[:error] = l(:error_can_not_delete_tracker) |
|
| 78 |
else |
|
| 79 |
@tracker.destroy |
|
| 80 |
end |
|
| 81 |
redirect_to :action => 'index' |
|
| 82 |
end |
|
| 83 |
|
|
| 84 |
def fields |
|
| 85 |
if request.post? && params[:trackers] |
|
| 86 |
params[:trackers].each do |tracker_id, tracker_params| |
|
| 87 |
tracker = Tracker.find_by_id(tracker_id) |
|
| 88 |
if tracker |
|
| 89 |
tracker.core_fields = tracker_params[:core_fields] |
|
| 90 |
tracker.custom_field_ids = tracker_params[:custom_field_ids] |
|
| 91 |
tracker.save |
|
| 92 |
end |
|
| 93 |
end |
|
| 94 |
flash[:notice] = l(:notice_successful_update) |
|
| 95 |
redirect_to :action => 'fields' |
|
| 96 |
return |
|
| 97 |
end |
|
| 98 |
@trackers = Tracker.sorted.all |
|
| 99 |
@custom_fields = IssueCustomField.all.sort |
|
| 100 |
end |
|
| 101 |
end |
|
Also available in: Unified diff