Revision 912:5e80956cc792 app/controllers

View differences:

app/controllers/account_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2009  Jean-Philippe Lang
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18 18
class AccountController < ApplicationController
19 19
  helper :custom_fields
20
  include CustomFieldsHelper   
21
  
20
  include CustomFieldsHelper
21

  
22 22
  # prevents login action to be filtered by check_if_login_required application scope filter
23 23
  skip_before_filter :check_if_login_required
24 24

  
......
36 36
    logout_user
37 37
    redirect_to home_url
38 38
  end
39
  
39

  
40 40
  # Enable user to choose a new password
41 41
  def lost_password
42 42
    redirect_to(home_url) && return unless Setting.lost_password?
......
51 51
          flash[:notice] = l(:notice_account_password_updated)
52 52
          redirect_to :action => 'login'
53 53
          return
54
        end 
54
        end
55 55
      end
56 56
      render :template => "account/password_recovery"
57 57
      return
......
73 73
      end
74 74
    end
75 75
  end
76
  
76

  
77 77
  # User self-registration
78 78
  def register
79 79
    redirect_to(home_url) && return unless Setting.self_registration? || session[:auth_source_registration]
......
122 122
      end
123 123
    end
124 124
  end
125
  
125

  
126 126
  # Token based account activation
127 127
  def activate
128 128
    redirect_to(home_url) && return unless Setting.self_registration? && params[:token]
......
137 137
    end
138 138
    redirect_to :action => 'login'
139 139
  end
140
  
140

  
141 141
  private
142
  
142

  
143 143
  def logout_user
144 144
    if User.current.logged?
145 145
      cookies.delete :autologin
......
147 147
      self.logged_user = nil
148 148
    end
149 149
  end
150
  
150

  
151 151
  def authenticate_user
152 152
    if Setting.openid? && using_open_id?
153 153
      open_id_authenticate(params[:openid_url])
......
169 169
    end
170 170
  end
171 171

  
172
  
173 172
  def open_id_authenticate(openid_url)
174 173
    authenticate_with_open_id(openid_url, :required => [:nickname, :fullname, :email], :return_to => signin_url) do |result, identity_url, registration|
175 174
      if result.successful?
......
198 197
            register_manually_by_administrator(user) do
199 198
              onthefly_creation_failed(user)
200 199
            end
201
          end          
200
          end
202 201
        else
203 202
          # Existing record
204 203
          if user.active?
......
210 209
      end
211 210
    end
212 211
  end
213
  
212

  
214 213
  def successful_authentication(user)
215 214
    # Valid user
216 215
    self.logged_user = user
......
221 220
    call_hook(:controller_account_success_authentication_after, {:user => user })
222 221
    redirect_back_or_default :controller => 'my', :action => 'page'
223 222
  end
224
  
223

  
225 224
  def set_autologin_cookie(user)
226 225
    token = Token.create(:user => user, :action => 'autologin')
227 226
    cookie_name = Redmine::Configuration['autologin_cookie_name'] || 'autologin'
......
260 259
      yield if block_given?
261 260
    end
262 261
  end
263
  
262

  
264 263
  # Automatically register a user
265 264
  #
266 265
  # Pass a block for behavior when a user fails to save
......
276 275
      yield if block_given?
277 276
    end
278 277
  end
279
  
278

  
280 279
  # Manual activation by the administrator
281 280
  #
282 281
  # Pass a block for behavior when a user fails to save
app/controllers/admin_controller.rb
1
# redMine - project management software
2
# Copyright (C) 2006  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
app/controllers/application_controller.rb
26 26
  layout 'base'
27 27
  exempt_from_layout 'builder', 'rsb'
28 28

  
29
  protect_from_forgery
30
  def handle_unverified_request
31
    super
32
    cookies.delete(:autologin)
33
  end
29 34
  # Remove broken cookie after upgrade from 0.8.x (#4292)
30 35
  # See https://rails.lighthouseapp.com/projects/8994/tickets/3360
31 36
  # TODO: remove it when Rails is fixed
......
40 45

  
41 46
  before_filter :user_setup, :check_if_login_required, :set_localization
42 47
  filter_parameter_logging :password
43
  protect_from_forgery
44 48

  
45 49
  rescue_from ActionController::InvalidAuthenticityToken, :with => :invalid_authenticity_token
46 50
  rescue_from ::Unauthorized, :with => :deny_access
......
202 206
    render_404 unless @object.present?
203 207

  
204 208
    @project = @object.project
205
  rescue ActiveRecord::RecordNotFound
206
    render_404
207 209
  end
208 210

  
209 211
  def find_model_object
......
250 252
      if @project.is_public? || User.current.member_of?(@project) || User.current.admin?
251 253
        true
252 254
      else
253
        User.current.logged? ? render_403 : require_login
255
        deny_access
254 256
      end
255 257
    else
256 258
      @project = nil
......
325 327
      format.json { head @status }
326 328
    end
327 329
  end
330
  
331
  # Filter for actions that provide an API response
332
  # but have no HTML representation for non admin users
333
  def require_admin_or_api_request
334
    return true if api_request?
335
    if User.current.admin?
336
      true
337
    elsif User.current.logged?
338
      render_error(:status => 406)
339
    else
340
      deny_access
341
    end
342
  end
328 343

  
329 344
  # Picks which layout to use based on the request
330 345
  #
......
345 360
    @items.sort! {|x,y| y.event_datetime <=> x.event_datetime }
346 361
    @items = @items.slice(0, Setting.feeds_limit.to_i)
347 362
    @title = options[:title] || Setting.app_title
348
    render :template => "common/feed.atom.rxml", :layout => false, :content_type => 'application/atom+xml'
363
    render :template => "common/feed.atom", :layout => false,
364
           :content_type => 'application/atom+xml'
349 365
  end
350
  
366

  
351 367
  # TODO: remove in Redmine 1.4
352 368
  def self.accept_key_auth(*actions)
353 369
    ActiveSupport::Deprecation.warn "ApplicationController.accept_key_auth is deprecated and will be removed in Redmine 1.4. Use accept_rss_auth (or accept_api_auth) instead."
......
359 375
    ActiveSupport::Deprecation.warn "ApplicationController.accept_key_auth_actions is deprecated and will be removed in Redmine 1.4. Use accept_rss_auth (or accept_api_auth) instead."
360 376
    self.class.accept_rss_auth
361 377
  end
362
  
378

  
363 379
  def self.accept_rss_auth(*actions)
364 380
    if actions.any?
365 381
      write_inheritable_attribute('accept_rss_auth_actions', actions)
......
367 383
      read_inheritable_attribute('accept_rss_auth_actions') || []
368 384
    end
369 385
  end
370
  
386

  
371 387
  def accept_rss_auth?(action=action_name)
372 388
    self.class.accept_rss_auth.include?(action.to_sym)
373 389
  end
374
  
390

  
375 391
  def self.accept_api_auth(*actions)
376 392
    if actions.any?
377 393
      write_inheritable_attribute('accept_api_auth_actions', actions)
......
379 395
      read_inheritable_attribute('accept_api_auth_actions') || []
380 396
    end
381 397
  end
382
  
398

  
383 399
  def accept_api_auth?(action=action_name)
384 400
    self.class.accept_api_auth.include?(action.to_sym)
385 401
  end
......
490 506
    render_error "An error occurred while executing the query and has been logged. Please report this error to your Redmine administrator."
491 507
  end
492 508

  
493
  # Converts the errors on an ActiveRecord object into a common JSON format
494
  def object_errors_to_json(object)
495
    object.errors.collect do |attribute, error|
496
      { attribute => error }
497
    end.to_json
498
  end
499

  
500 509
  # Renders API response on validation failure
501 510
  def render_validation_errors(object)
502 511
    options = { :status => :unprocessable_entity, :layout => false }
app/controllers/attachments_controller.rb
22 22
  before_filter :delete_authorize, :only => :destroy
23 23
  before_filter :active_authorize, :only => :toggle_active
24 24

  
25
  verify :method => :post, :only => :destroy
25
  accept_api_auth :show, :download
26 26

  
27 27
  def show
28
    if @attachment.is_diff?
29
      @diff = File.new(@attachment.diskfile, "rb").read
30
      render :action => 'diff'
31
    elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte
32
      @content = File.new(@attachment.diskfile, "rb").read
33
      render :action => 'file'
34
    else
35
      download
28
    respond_to do |format|
29
      format.html {
30
        if @attachment.is_diff?
31
          @diff = File.new(@attachment.diskfile, "rb").read
32
          @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
33
          @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
34
          # Save diff type as user preference
35
          if User.current.logged? && @diff_type != User.current.pref[:diff_type]
36
            User.current.pref[:diff_type] = @diff_type
37
            User.current.preference.save
38
          end
39
          render :action => 'diff'
40
        elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte
41
          @content = File.new(@attachment.diskfile, "rb").read
42
          render :action => 'file'
43
        else
44
          download
45
        end
46
      }
47
      format.api
36 48
    end
37 49
  end
38 50

  
......
48 60

  
49 61
  end
50 62

  
63
  verify :method => :delete, :only => :destroy
51 64
  def destroy
52 65
    # Make sure association callbacks are called
53 66
    @attachment.container.attachments.delete(@attachment)
app/controllers/auth_sources_controller.rb
1
# redMine - project management software
2
# Copyright (C) 2006  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18 18
class AuthSourcesController < ApplicationController
19 19
  layout 'admin'
20
  
20

  
21 21
  before_filter :require_admin
22 22

  
23 23
  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
......
58 58
      render 'auth_sources/edit'
59 59
    end
60 60
  end
61
  
61

  
62 62
  def test_connection
63 63
    @auth_method = AuthSource.find(params[:id])
64 64
    begin
app/controllers/auto_completes_controller.rb
1 1
class AutoCompletesController < ApplicationController
2 2
  before_filter :find_project
3
  
3

  
4 4
  def issues
5 5
    @issues = []
6 6
    q = params[:q].to_s
app/controllers/boards_controller.rb
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
......
26 26
  include SortHelper
27 27
  helper :watchers
28 28
  include WatchersHelper
29
 
29

  
30 30
  def index
31 31
    @boards = @project.boards
32 32
    # show the board if there is only one
......
43 43
        sort_update	'created_on' => "#{Message.table_name}.created_on",
44 44
                    'replies' => "#{Message.table_name}.replies_count",
45 45
                    'updated_on' => "#{Message.table_name}.updated_on"
46
          
46

  
47 47
        @topic_count = @board.topics.count
48 48
        @topic_pages = Paginator.new self, @topic_count, per_page_option, params['page']
49 49
        @topics =  @board.topics.find :all, :order => ["#{Message.table_name}.sticky DESC", sort_clause].compact.join(', '),
......
61 61
      }
62 62
    end
63 63
  end
64
  
64

  
65 65
  verify :method => :post, :only => [ :destroy ], :redirect_to => { :action => :index }
66 66

  
67 67
  def new
......
83 83
    @board.destroy
84 84
    redirect_to_settings_in_projects
85 85
  end
86
  
86

  
87 87
private
88 88
  def redirect_to_settings_in_projects
89 89
    redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'boards'
app/controllers/calendars_controller.rb
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
......
33 33
      @year = params[:year].to_i
34 34
      if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
35 35
        @month = params[:month].to_i
36
      end    
36
      end
37 37
    end
38 38
    @year ||= Date.today.year
39 39
    @month ||= Date.today.month
40
    
40

  
41 41
    @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
42 42
    retrieve_query
43 43
    @query.group_by = nil
......
47 47
                              :conditions => ["((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))", @calendar.startdt, @calendar.enddt, @calendar.startdt, @calendar.enddt]
48 48
                              )
49 49
      events += @query.versions(:conditions => ["effective_date BETWEEN ? AND ?", @calendar.startdt, @calendar.enddt])
50
                                     
50

  
51 51
      @calendar.events = events
52 52
    end
53
    
53

  
54 54
    render :action => 'show', :layout => false if request.xhr?
55 55
  end
56 56
end
app/controllers/comments_controller.rb
12 12
    if @news.comments << @comment
13 13
      flash[:notice] = l(:label_comment_added)
14 14
    end
15
    
15

  
16 16
    redirect_to :controller => 'news', :action => 'show', :id => @news
17 17
  end
18 18

  
......
32 32
    @comment = nil
33 33
    @news
34 34
  end
35
  
35

  
36 36
end
app/controllers/context_menus_controller.rb
1 1
class ContextMenusController < ApplicationController
2 2
  helper :watchers
3 3
  helper :issues
4
  
4

  
5 5
  def issues
6 6
    @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
7
    
7

  
8 8
    if (@issues.size == 1)
9 9
      @issue = @issues.first
10 10
      @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
......
26 26
            :delete => User.current.allowed_to?(:delete_issues, @projects)
27 27
            }
28 28
    if @project
29
      @assignables = @project.assignable_users
30
      @assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to)
29
      if @issue
30
        @assignables = @issue.assignable_users
31
      else
32
        @assignables = @project.assignable_users
33
      end
31 34
      @trackers = @project.trackers
32 35
    else
33 36
      #when multiple projects, we only keep the intersection of each set
34 37
      @assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a}
35 38
      @trackers = @projects.map(&:trackers).inject{|memo,t| memo & t}
36 39
    end
37
    
38
    @priorities = IssuePriority.all.reverse
40

  
41
    @priorities = IssuePriority.active.reverse
39 42
    @statuses = IssueStatus.find(:all, :order => 'position')
40 43
    @back = back_url
41
    
44

  
42 45
    render :layout => false
43 46
  end
44 47

  
......
48 51
    @projects = @time_entries.collect(&:project).compact.uniq
49 52
    @project = @projects.first if @projects.size == 1
50 53
    @activities = TimeEntryActivity.shared.active
51
    @can = {:edit   => User.current.allowed_to?(:log_time, @projects),
52
            :update => User.current.allowed_to?(:log_time, @projects),
53
            :delete => User.current.allowed_to?(:log_time, @projects)
54
    @can = {:edit   => User.current.allowed_to?(:edit_time_entries, @projects),
55
            :delete => User.current.allowed_to?(:edit_time_entries, @projects)
54 56
            }
55 57
    @back = back_url
56 58
    render :layout => false
57
  end  
59
  end
58 60
end
app/controllers/custom_fields_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2009  Jean-Philippe Lang
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18 18
class CustomFieldsController < ApplicationController
19 19
  layout 'admin'
20
  
20

  
21 21
  before_filter :require_admin
22 22

  
23 23
  def index
24 24
    @custom_fields_by_type = CustomField.find(:all).group_by {|f| f.class.name }
25 25
    @tab = params[:tab] || 'IssueCustomField'
26 26
  end
27
  
27

  
28 28
  def new
29 29
    @custom_field = begin
30 30
      if params[:type].to_s.match(/.+CustomField$/)
......
33 33
    rescue
34 34
    end
35 35
    (redirect_to(:action => 'index'); return) unless @custom_field.is_a?(CustomField)
36
    
36

  
37 37
    if request.post? and @custom_field.save
38 38
      flash[:notice] = l(:notice_successful_create)
39 39
      call_hook(:controller_custom_fields_new_after_save, :params => params, :custom_field => @custom_field)
......
53 53
      @trackers = Tracker.find(:all, :order => 'position')
54 54
    end
55 55
  end
56
  
56

  
57 57
  def destroy
58 58
    @custom_field = CustomField.find(params[:id]).destroy
59 59
    redirect_to :action => 'index', :tab => @custom_field.class.name
app/controllers/documents_controller.rb
1
# redMine - project management software
2
# Copyright (C) 2006-2007  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
......
22 22
  before_filter :find_model_object, :except => [:index, :new]
23 23
  before_filter :find_project_from_association, :except => [:index, :new]
24 24
  before_filter :authorize
25
  
25

  
26 26
  helper :attachments
27
  
27

  
28 28
  def index
29 29
    @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
30 30
    documents = @project.documents.find :all, :include => [:attachments, :category]
......
41 41
    @document = @project.documents.build
42 42
    render :layout => false if request.xhr?
43 43
  end
44
  
44

  
45 45
  def show
46 46
    @attachments = @document.attachments.find(:all, :order => "created_on DESC")
47 47
  end
48 48

  
49 49
  def new
50
    @document = @project.documents.build(params[:document])    
50
    @document = @project.documents.build(params[:document])
51 51
    if request.post? and @document.save	
52 52
      attachments = Attachment.attach_files(@document, params[:attachments])
53 53
      render_attachment_warning_if_needed(@document)
......
55 55
      redirect_to :action => 'index', :project_id => @project
56 56
    end
57 57
  end
58
  
58

  
59 59
  def edit
60
    @categories = DocumentCategory.all
60
    @categories = DocumentCategory.active #TODO: use it in the views
61 61
    if request.post? and @document.update_attributes(params[:document])
62 62
      flash[:notice] = l(:notice_successful_update)
63 63
      redirect_to :action => 'show', :id => @document
64 64
    end
65
  end  
65
  end
66 66

  
67 67
  def destroy
68 68
    @document.destroy
69 69
    redirect_to :controller => 'documents', :action => 'index', :project_id => @project
70 70
  end
71
  
71

  
72 72
  def add_attachment
73 73
    attachments = Attachment.attach_files(@document, params[:attachments])
74 74
    render_attachment_warning_if_needed(@document)
app/controllers/enumerations_controller.rb
1
# redMine - project management software
2
# Copyright (C) 2006  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18 18
class EnumerationsController < ApplicationController
19 19
  layout 'admin'
20
  
20

  
21 21
  before_filter :require_admin
22 22

  
23 23
  helper :custom_fields
24 24
  include CustomFieldsHelper
25
  
25

  
26 26
  def index
27
    list
28
    render :action => 'list'
29 27
  end
30 28

  
31
  # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
32 29
  verify :method => :post, :only => [ :destroy, :create, :update ],
33
         :redirect_to => { :action => :list }
34

  
35
  def list
36
  end
30
         :redirect_to => { :action => :index }
37 31

  
38 32
  def new
39 33
    begin
40 34
      @enumeration = params[:type].constantize.new
41 35
    rescue NameError
42
      @enumeration = Enumeration.new      
36
      @enumeration = Enumeration.new
43 37
    end
44 38
  end
45 39

  
......
48 42
    @enumeration.type = params[:enumeration][:type]
49 43
    if @enumeration.save
50 44
      flash[:notice] = l(:notice_successful_create)
51
      redirect_to :action => 'list', :type => @enumeration.type
45
      redirect_to :action => 'index', :type => @enumeration.type
52 46
    else
53 47
      render :action => 'new'
54 48
    end
......
63 57
    @enumeration.type = params[:enumeration][:type] if params[:enumeration][:type]
64 58
    if @enumeration.update_attributes(params[:enumeration])
65 59
      flash[:notice] = l(:notice_successful_update)
66
      redirect_to :action => 'list', :type => @enumeration.type
60
      redirect_to :action => 'index', :type => @enumeration.type
67 61
    else
68 62
      render :action => 'edit'
69 63
    end
70 64
  end
71
  
65

  
72 66
  def destroy
73 67
    @enumeration = Enumeration.find(params[:id])
74 68
    if !@enumeration.in_use?
app/controllers/gantts_controller.rb
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
......
29 29
  helper :sort
30 30
  include SortHelper
31 31
  include Redmine::Export::PDF
32
  
32

  
33 33
  def show
34 34
    @gantt = Redmine::Helpers::Gantt.new(params)
35 35
    @gantt.project = @project
36 36
    retrieve_query
37 37
    @query.group_by = nil
38 38
    @gantt.query = @query if @query.valid?
39
    
39

  
40 40
    basename = (@project ? "#{@project.identifier}-" : '') + 'gantt'
41
    
41

  
42 42
    respond_to do |format|
43 43
      format.html { render :action => "show", :layout => !request.xhr? }
44 44
      format.png  { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image')
app/controllers/groups_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2009  Jean-Philippe Lang
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18 18
class GroupsController < ApplicationController
19 19
  layout 'admin'
20
  
20

  
21 21
  before_filter :require_admin
22
  
22

  
23 23
  helper :custom_fields
24
  
24

  
25 25
  # GET /groups
26 26
  # GET /groups.xml
27 27
  def index
......
48 48
  # GET /groups/new.xml
49 49
  def new
50 50
    @group = Group.new
51
    
51

  
52 52
    respond_to do |format|
53 53
      format.html # new.html.erb
54 54
      format.xml  { render :xml => @group }
......
67 67

  
68 68
    respond_to do |format|
69 69
      if @group.save
70
        flash[:notice] = l(:notice_successful_create)
71
        format.html { redirect_to(groups_path) }
70
        format.html {
71
          flash[:notice] = l(:notice_successful_create)
72
          redirect_to(params[:continue] ? new_group_path : groups_path)
73
        }
72 74
        format.xml  { render :xml => @group, :status => :created, :location => @group }
73 75
      else
74 76
        format.html { render :action => "new" }
......
105 107
      format.xml  { head :ok }
106 108
    end
107 109
  end
108
  
110

  
109 111
  def add_users
110 112
    @group = Group.find(params[:id])
111 113
    users = User.find_all_by_id(params[:user_ids])
112 114
    @group.users << users if request.post?
113 115
    respond_to do |format|
114 116
      format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
115
      format.js { 
116
        render(:update) {|page| 
117
      format.js {
118
        render(:update) {|page|
117 119
          page.replace_html "tab-content-users", :partial => 'groups/users'
118 120
          users.each {|user| page.visual_effect(:highlight, "user-#{user.id}") }
119 121
        }
120 122
      }
121 123
    end
122 124
  end
123
  
125

  
124 126
  def remove_user
125 127
    @group = Group.find(params[:id])
126
    @group.users.delete(User.find(params[:user_id])) if request.post?
128
    @group.users.delete(User.find(params[:user_id])) if request.delete?
127 129
    respond_to do |format|
128 130
      format.html { redirect_to :controller => 'groups', :action => 'edit', :id => @group, :tab => 'users' }
129 131
      format.js { render(:update) {|page| page.replace_html "tab-content-users", :partial => 'groups/users'} }
130 132
    end
131 133
  end
132
  
134

  
133 135
  def autocomplete_for_user
134 136
    @group = Group.find(params[:id])
135 137
    @users = User.active.not_in_group(@group).like(params[:q]).all(:limit => 100)
136 138
    render :layout => false
137 139
  end
138
  
140

  
139 141
  def edit_membership
140 142
    @group = Group.find(params[:id])
141 143
    @membership = Member.edit_membership(params[:membership_id], params[:membership], @group)
......
158 160
      end
159 161
    end
160 162
  end
161
  
163

  
162 164
  def destroy_membership
163 165
    @group = Group.find(params[:id])
164 166
    Member.find(params[:membership_id]).destroy if request.post?
app/controllers/issue_categories_controller.rb
1
# redMine - project management software
2
# Copyright (C) 2006  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
......
18 18
class IssueCategoriesController < ApplicationController
19 19
  menu_item :settings
20 20
  model_object IssueCategory
21
  before_filter :find_model_object, :except => :new
22
  before_filter :find_project_from_association, :except => :new
23
  before_filter :find_project, :only => :new
21
  before_filter :find_model_object, :except => [:index, :new, :create]
22
  before_filter :find_project_from_association, :except => [:index, :new, :create]
23
  before_filter :find_project, :only => [:index, :new, :create]
24 24
  before_filter :authorize
25
  accept_api_auth :index, :show, :create, :update, :destroy
25 26
  
26
  verify :method => :post, :only => :destroy
27
  def index
28
    respond_to do |format|
29
      format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project }
30
      format.api { @categories = @project.issue_categories.all }
31
    end
32
  end
33

  
34
  def show
35
    respond_to do |format|
36
      format.html { redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project }
37
      format.api
38
    end
39
  end
27 40

  
28 41
  def new
29
    @category = @project.issue_categories.build(params[:category])
30
    if request.post?
31
      if @category.save
32
        respond_to do |format|
33
          format.html do
34
            flash[:notice] = l(:notice_successful_create)
35
            redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
36
          end
37
          format.js do
38
            # IE doesn't support the replace_html rjs method for select box options
39
            render(:update) {|page| page.replace "issue_category_id",
40
              content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
41
            }
42
          end
42
    @category = @project.issue_categories.build(params[:issue_category])
43
  end
44

  
45
  verify :method => :post, :only => :create
46
  def create
47
    @category = @project.issue_categories.build(params[:issue_category])
48
    if @category.save
49
      respond_to do |format|
50
        format.html do
51
          flash[:notice] = l(:notice_successful_create)
52
          redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
43 53
        end
44
      else
45
        respond_to do |format|
46
          format.html
47
          format.js do
48
            render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) }
49
          end
54
        format.js do
55
          # IE doesn't support the replace_html rjs method for select box options
56
          render(:update) {|page| page.replace "issue_category_id",
57
            content_tag('select', '<option></option>' + options_from_collection_for_select(@project.issue_categories, 'id', 'name', @category.id), :id => 'issue_category_id', :name => 'issue[category_id]')
58
          }
50 59
        end
60
        format.api { render :action => 'show', :status => :created, :location => issue_category_path(@category) }
61
      end
62
    else
63
      respond_to do |format|
64
        format.html { render :action => 'new'}
65
        format.js do
66
          render(:update) {|page| page.alert(@category.errors.full_messages.join('\n')) }
67
        end
68
        format.api { render_validation_errors(@category) }
51 69
      end
52 70
    end
53 71
  end
54
  
72

  
55 73
  def edit
56
    if request.post? and @category.update_attributes(params[:category])
57
      flash[:notice] = l(:notice_successful_update)
58
      redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
74
  end
75

  
76
  verify :method => :put, :only => :update
77
  def update
78
    if @category.update_attributes(params[:issue_category])
79
      respond_to do |format|
80
        format.html {
81
          flash[:notice] = l(:notice_successful_update)
82
          redirect_to :controller => 'projects', :action => 'settings', :tab => 'categories', :id => @project
83
        }
84
        format.api { head :ok }
85
      end
86
    else
87
      respond_to do |format|
88
        format.html { render :action => 'edit' }
89
        format.api { render_validation_errors(@category) }
90
      end
59 91
    end
60 92
  end
61 93

  
94
  verify :method => :delete, :only => :destroy
62 95
  def destroy
63 96
    @issue_count = @category.issues.size
64
    if @issue_count == 0
65
      # No issue assigned to this category
66
      @category.destroy
67
      redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
68
      return
69
    elsif params[:todo]
70
      reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id]) if params[:todo] == 'reassign'
97
    if @issue_count == 0 || params[:todo] || api_request? 
98
      reassign_to = nil
99
      if params[:reassign_to_id] && (params[:todo] == 'reassign' || params[:todo].blank?)
100
        reassign_to = @project.issue_categories.find_by_id(params[:reassign_to_id])
101
      end
71 102
      @category.destroy(reassign_to)
72
      redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories'
103
      respond_to do |format|
104
        format.html { redirect_to :controller => 'projects', :action => 'settings', :id => @project, :tab => 'categories' }
105
        format.api { head :ok }
106
      end
73 107
      return
74 108
    end
75 109
    @categories = @project.issue_categories - [@category]
......
81 115
  def find_model_object
82 116
    super
83 117
    @category = @object
84
  end    
85
  
118
  end
119

  
86 120
  def find_project
87 121
    @project = Project.find(params[:project_id])
88 122
  rescue ActiveRecord::RecordNotFound
app/controllers/issue_moves_controller.rb
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  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

  
1 18
class IssueMovesController < ApplicationController
19
  menu_item :issues
20

  
2 21
  default_search_scope :issues
3 22
  before_filter :find_issues, :check_project_uniqueness
4 23
  before_filter :authorize
app/controllers/issue_relations_controller.rb
1 1
# Redmine - project management software
2
# Copyright (C) 2006-2007  Jean-Philippe Lang
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18 18
class IssueRelationsController < ApplicationController
19
  before_filter :find_issue, :find_project_from_association, :authorize
20
  
21
  def new
19
  before_filter :find_issue, :find_project_from_association, :authorize, :only => [:index, :create]
20
  before_filter :find_relation, :except => [:index, :create]
21

  
22
  accept_api_auth :index, :show, :create, :destroy
23

  
24
  def index
25
    @relations = @issue.relations
26

  
27
    respond_to do |format|
28
      format.html { render :nothing => true }
29
      format.api
30
    end
31
  end
32

  
33
  def show
34
    raise Unauthorized unless @relation.visible?
35

  
36
    respond_to do |format|
37
      format.html { render :nothing => true }
38
      format.api
39
    end
40
  end
41

  
42
  verify :method => :post, :only => :create, :render => {:nothing => true, :status => :method_not_allowed }
43
  def create
22 44
    @relation = IssueRelation.new(params[:relation])
23 45
    @relation.issue_from = @issue
24 46
    if params[:relation] && m = params[:relation][:issue_to_id].to_s.match(/^#?(\d+)$/)
25 47
      @relation.issue_to = Issue.visible.find_by_id(m[1].to_i)
26 48
    end
27
    @relation.save if request.post?
49
    saved = @relation.save
50

  
28 51
    respond_to do |format|
29 52
      format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
30 53
      format.js do
......
37 60
          end
38 61
        end
39 62
      end
40
    end
41
  end
42
  
43
  def destroy
44
    relation = IssueRelation.find(params[:id])
45
    if request.post? && @issue.relations.include?(relation)
46
      relation.destroy
47
      @issue.reload
48
    end
49
    respond_to do |format|
50
      format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
51
      format.js {
52
        @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
53
        render(:update) {|page| page.replace_html "relations", :partial => 'issues/relations'}
63
      format.api {
64
        if saved
65
          render :action => 'show', :status => :created, :location => relation_url(@relation)
66
        else
67
          render_validation_errors(@relation)
68
        end
54 69
      }
55 70
    end
56 71
  end
57
  
72

  
73
  verify :method => :delete, :only => :destroy, :render => {:nothing => true, :status => :method_not_allowed }
74
  def destroy
75
    raise Unauthorized unless @relation.deletable?
76
    @relation.destroy
77

  
78
    respond_to do |format|
79
      format.html { redirect_to :controller => 'issues', :action => 'show', :id => @issue }
80
      format.js   { render(:update) {|page| page.remove "relation-#{@relation.id}"} }
81
      format.api  { head :ok }
82
    end
83
  end
84

  
58 85
private
59 86
  def find_issue
60 87
    @issue = @object = Issue.find(params[:issue_id])
61 88
  rescue ActiveRecord::RecordNotFound
62 89
    render_404
63 90
  end
91

  
92
  def find_relation
93
    @relation = IssueRelation.find(params[:id])
94
  rescue ActiveRecord::RecordNotFound
95
    render_404
96
  end
64 97
end
app/controllers/issue_statuses_controller.rb
1
# redMine - project management software
2
# Copyright (C) 2006  Jean-Philippe Lang
1
# Redmine - project management software
2
# Copyright (C) 2006-2011  Jean-Philippe Lang
3 3
#
4 4
# This program is free software; you can redistribute it and/or
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 17

  
18 18
class IssueStatusesController < ApplicationController
19 19
  layout 'admin'
20
  
21
  before_filter :require_admin
22 20

  
23
  verify :method => :post, :only => [ :destroy, :create, :update, :move, :update_issue_done_ratio ],
24
         :redirect_to => { :action => :index }
25
         
21
  before_filter :require_admin, :except => :index
22
  before_filter :require_admin_or_api_request, :only => :index
23
  accept_api_auth :index
24

  
26 25
  def index
27
    @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
28
    render :action => "index", :layout => false if request.xhr?
26
    respond_to do |format|
27
      format.html {
28
        @issue_status_pages, @issue_statuses = paginate :issue_statuses, :per_page => 25, :order => "position"
29
        render :action => "index", :layout => false if request.xhr?
30
      }
31
      format.api {
32
        @issue_statuses = IssueStatus.all(:order => 'position')
33
      }
34
    end
29 35
  end
30 36

  
31 37
  def new
......
34 40

  
35 41
  def create
36 42
    @issue_status = IssueStatus.new(params[:issue_status])
37
    if @issue_status.save
43
    if request.post? && @issue_status.save
38 44
      flash[:notice] = l(:notice_successful_create)
39 45
      redirect_to :action => 'index'
40 46
    else
......
48 54

  
49 55
  def update
50 56
    @issue_status = IssueStatus.find(params[:id])
51
    if @issue_status.update_attributes(params[:issue_status])
57
    if request.put? && @issue_status.update_attributes(params[:issue_status])
52 58
      flash[:notice] = l(:notice_successful_update)
53 59
      redirect_to :action => 'index'
54 60
    else
......
56 62
    end
57 63
  end
58 64

  
65
  verify :method => :delete, :only => :destroy, :redirect_to => { :action => :index }
59 66
  def destroy
60 67
    IssueStatus.find(params[:id]).destroy
61 68
    redirect_to :action => 'index'
......
63 70
    flash[:error] = l(:error_unable_delete_issue_status)
64 71
    redirect_to :action => 'index'
65 72
  end  	
66
  
73

  
67 74
  def update_issue_done_ratio
68
    if IssueStatus.update_issue_done_ratios
75
    if request.post? && IssueStatus.update_issue_done_ratios
69 76
      flash[:notice] = l(:notice_issue_done_ratios_updated)
70 77
    else
71 78
      flash[:error] =  l(:error_issue_done_ratios_not_updated)
app/controllers/issues_controller.rb
89 89
      @issue_count_by_group = @query.issue_count_by_group
90 90

  
91 91
      respond_to do |format|
92
        format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
93
        format.api
92
        format.html { render :template => 'issues/index', :layout => !request.xhr? }
93
        format.api  {
94
          Issue.load_relations(@issues) if include_in_api_response?('relations')
95
        }
94 96
        format.atom { render_feed(@issues, :title => "#{@project || Setting.app_title}: #{l(:label_issue_plural)}") }
95
        format.csv  { send_data(issues_to_csv(@issues, @project), :type => 'text/csv; header=present', :filename => 'export.csv') }
97
        format.csv  { send_data(issues_to_csv(@issues, @project, @query, params), :type => 'text/csv; header=present', :filename => 'export.csv') }
96 98
        format.pdf  { send_data(issues_to_pdf(@issues, @project, @query), :type => 'application/pdf', :filename => 'export.pdf') }
97 99
      end
98 100
    else
99
      # Send html if the query is not valid
100
      render(:template => 'issues/index.rhtml', :layout => !request.xhr?)
101
      respond_to do |format|
102
        format.html { render(:template => 'issues/index', :layout => !request.xhr?) }
103
        format.any(:atom, :csv, :pdf) { render(:nothing => true) }
104
        format.api { render_validation_errors(@query) }
105
      end
101 106
    end
102 107
  rescue ActiveRecord::RecordNotFound
103 108
    render_404
......
116 121
    @relations = @issue.relations.select {|r| r.other_issue(@issue) && r.other_issue(@issue).visible? }
117 122
    @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
118 123
    @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
119
    @priorities = IssuePriority.all
124
    @priorities = IssuePriority.active
120 125
    @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
121 126
    respond_to do |format|
122
      format.html { render :template => 'issues/show.rhtml' }
127
      format.html { render :template => 'issues/show' }
123 128
      format.api
124 129
      format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' }
125 130
      format.pdf  { send_data(issue_to_pdf(@issue), :type => 'application/pdf', :filename => "#{@project.identifier}-#{@issue.id}.pdf") }
......
139 144
    call_hook(:controller_issues_new_before_save, { :params => params, :issue => @issue })
140 145
    if @issue.save
141 146
      attachments = Attachment.attach_files(@issue, params[:attachments])
142
      render_attachment_warning_if_needed(@issue)
143
      flash[:notice] = l(:notice_successful_create)
144 147
      
145 148
      call_hook(:controller_issues_new_after_save, { :params => params, :issue => @issue})
146 149

  
......
153 156

  
154 157
      respond_to do |format|
155 158
        format.html {
159
          render_attachment_warning_if_needed(@issue)
160
          flash[:notice] = l(:notice_issue_successful_create, :id => "<a href='#{issue_path(@issue)}'>##{@issue.id}</a>")
156 161
          redirect_to(params[:continue] ?  { :action => 'new', :project_id => @project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
157 162
                      { :action => 'show', :id => @issue })
158 163
        }
......
289 294
  # TODO: Refactor, not everything in here is needed by #edit
290 295
  def update_issue_from_params
291 296
    @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
292
    @priorities = IssuePriority.all
297
    @priorities = IssuePriority.active
293 298
    @edit_allowed = User.current.allowed_to?(:edit_issues, @project)
294 299
    @time_entry = TimeEntry.new(:issue => @issue, :project => @issue.project)
295 300
    @time_entry.attributes = params[:time_entry]
......
330 335
      render_error l(:error_no_tracker_in_project)
331 336
      return false
332 337
    end
333
    @issue.start_date ||= Date.today
338
    @issue.start_date ||= Date.today if Setting.default_issue_start_date_to_creation_date?
334 339
    if params[:issue].is_a?(Hash)
335 340
      @issue.safe_attributes = params[:issue]
336 341
      if User.current.allowed_to?(:add_issue_watchers, @project) && @issue.new_record?
337 342
        @issue.watcher_user_ids = params[:issue]['watcher_user_ids']
338 343
      end
339 344
    end
340
    @priorities = IssuePriority.all
345
    @priorities = IssuePriority.active
341 346
    @allowed_statuses = @issue.new_statuses_allowed_to(User.current, true)
342 347
  end
343 348

  
app/controllers/journals_controller.rb
5 5
# modify it under the terms of the GNU General Public License
6 6
# as published by the Free Software Foundation; either version 2
7 7
# of the License, or (at your option) any later version.
8
# 
8
#
9 9
# This program is distributed in the hope that it will be useful,
10 10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 12
# GNU General Public License for more details.
13
# 
13
#
14 14
# You should have received a copy of the GNU General Public License
15 15
# along with this program; if not, write to the Free Software
16 16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
......
22 22
  before_filter :authorize, :only => [:new, :edit, :diff]
23 23
  accept_rss_auth :index
24 24
  menu_item :issues
25
  
25

  
26 26
  helper :issues
27 27
  helper :custom_fields
28 28
  helper :queries
......
34 34
    retrieve_query
35 35
    sort_init 'id', 'desc'
36 36
    sort_update(@query.sortable_columns)
37
    
37

  
38 38
    if @query.valid?
39
      @journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC", 
39
      @journals = @query.journals(:order => "#{Journal.table_name}.created_on DESC",
40 40
                                  :limit => 25)
41 41
    end
42 42
    @title = (@project ? @project.name : Setting.app_title) + ": " + (@query.new_record? ? l(:label_changes_details) : @query.name)
......
44 44
  rescue ActiveRecord::RecordNotFound
45 45
    render_404
46 46
  end
47
  
47

  
48 48
  def diff
49 49
    @issue = @journal.issue
50 50
    if params[:detail_id].present?
......
55 55
    (render_404; return false) unless @issue && @detail
56 56
    @diff = Redmine::Helpers::Diff.new(@detail.value, @detail.old_value)
57 57
  end
58
  
58

  
59 59
  def new
60 60
    journal = Journal.find(params[:journal_id]) if params[:journal_id]
61 61
    if journal
......
69 69
    text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
70 70
    content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> "
71 71
    content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
72
      
72

  
73 73
    render(:update) { |page|
74 74
      page.<< "$('notes').value = \"#{escape_javascript content}\";"
75 75
      page.show 'update'
......
78 78
      page << "$('notes').scrollTop = $('notes').scrollHeight - $('notes').clientHeight;"
79 79
    }
80 80
  end
81
  
81

  
82 82
  def edit
83 83
    (render_403; return false) unless @journal.editable_by?(User.current)
84 84
    if request.post?
......
93 93
      respond_to do |format|
94 94
        format.html {
95 95
          # TODO: implement non-JS journal update
96
          render :nothing => true 
96
          render :nothing => true
97 97
        }
98 98
        format.js
99 99
      end
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff