To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / app / controllers / trackers_controller.rb @ 1535:e2c122809c5c

History | View | Annotate | Download (2.9 KB)

1 0:513646585e45 Chris
# Redmine - project management software
2 1494:e248c7af89ec Chris
# Copyright (C) 2006-2014  Jean-Philippe Lang
3 0:513646585e45 Chris
#
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 909:cbb26bc654de Chris
#
9 0:513646585e45 Chris
# 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 909:cbb26bc654de Chris
#
14 0:513646585e45 Chris
# 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 909:cbb26bc654de Chris
  before_filter :require_admin, :except => :index
22
  before_filter :require_admin_or_api_request, :only => :index
23
  accept_api_auth :index
24 0:513646585e45 Chris
25
  def index
26 909:cbb26bc654de Chris
    respond_to do |format|
27
      format.html {
28 1464:261b3d9a4903 Chris
        @tracker_pages, @trackers = paginate Tracker.sorted, :per_page => 25
29 909:cbb26bc654de Chris
        render :action => "index", :layout => false if request.xhr?
30
      }
31
      format.api {
32 1115:433d4f72a19b Chris
        @trackers = Tracker.sorted.all
33 909:cbb26bc654de Chris
      }
34
    end
35 0:513646585e45 Chris
  end
36
37
  def new
38 909:cbb26bc654de Chris
    @tracker ||= Tracker.new(params[:tracker])
39 1464:261b3d9a4903 Chris
    @trackers = Tracker.sorted.all
40
    @projects = Project.all
41 909:cbb26bc654de Chris
  end
42
43
  def create
44 0:513646585e45 Chris
    @tracker = Tracker.new(params[:tracker])
45 1464:261b3d9a4903 Chris
    if @tracker.save
46 0:513646585e45 Chris
      # workflow copy
47
      if !params[:copy_workflow_from].blank? && (copy_from = Tracker.find_by_id(params[:copy_workflow_from]))
48 1115:433d4f72a19b Chris
        @tracker.workflow_rules.copy(copy_from)
49 0:513646585e45 Chris
      end
50
      flash[:notice] = l(:notice_successful_create)
51 1464:261b3d9a4903 Chris
      redirect_to trackers_path
52 0:513646585e45 Chris
      return
53
    end
54 909:cbb26bc654de Chris
    new
55
    render :action => 'new'
56 0:513646585e45 Chris
  end
57
58
  def edit
59 909:cbb26bc654de Chris
    @tracker ||= Tracker.find(params[:id])
60 1464:261b3d9a4903 Chris
    @projects = Project.all
61 909:cbb26bc654de Chris
  end
62 1115:433d4f72a19b Chris
63 909:cbb26bc654de Chris
  def update
64 0:513646585e45 Chris
    @tracker = Tracker.find(params[:id])
65 1464:261b3d9a4903 Chris
    if @tracker.update_attributes(params[:tracker])
66 0:513646585e45 Chris
      flash[:notice] = l(:notice_successful_update)
67 1464:261b3d9a4903 Chris
      redirect_to trackers_path
68 0:513646585e45 Chris
      return
69
    end
70 909:cbb26bc654de Chris
    edit
71
    render :action => 'edit'
72 0:513646585e45 Chris
  end
73 909:cbb26bc654de Chris
74 0:513646585e45 Chris
  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 1464:261b3d9a4903 Chris
    redirect_to trackers_path
82 909:cbb26bc654de Chris
  end
83 1115:433d4f72a19b Chris
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 1464:261b3d9a4903 Chris
      redirect_to fields_trackers_path
96 1115:433d4f72a19b Chris
      return
97
    end
98
    @trackers = Tracker.sorted.all
99
    @custom_fields = IssueCustomField.all.sort
100
  end
101 0:513646585e45 Chris
end